﻿using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Data;
using System.Data.OracleClient;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        //WASTAMM WTSCHUSS WAFARBEN WTGEW WASTKE WASTGA BSSATZ BHSATZ BSGROE BSFARB BASTGA
        #region====MintexDB===========
        public void CompressMainkey(DataTable tb)
        {
            if (!tb.Columns.Contains("MAINKEY"))
                return;
            foreach (DataRow row in tb.Rows)
            {
                row["MAINKEY"] = DataToXml.CompressLongString(row["MAINKEY"].ToString());
            }
        }
        public XDocument QueryGPBST(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "GPBST";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT ROWNUM AS MAINKEY,GPBMANDANT,GPBPARTIE,GPBART,GPBVAR,GPBFARBE,GPBBSTKGG,GPBART AS PHOTO FROM GPBST WHERE GPBMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (GPBNEUDAT>=" + today + " OR GPBAENDDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("GPBMANDANT");
                keylist.Add("GPBPARTIE");
                keylist.Add("GPBART");
                keylist.Add("GPBVAR");
                keylist.Add("GPBFARBE");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex) { }
            return doc;
        }
        public XDocument QueryWBDAT(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "WBDAT";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY, WBMANDANT,WBWAKZ,WBART,WBVAR,WBCOLORIT,WBFARBE,WBBESCHICH,"
                + " WBZUSTAND,WBSTK,WBMTR FROM WBDAT WHERE WBMANDANT='00'";
                if (dwData != null)
                {
                    or1.CommandText = "SELECT  ROWNUM AS MAINKEY, WBMANDANT,WBWAKZ,WBART,WBVAR,WBCOLORIT,WBFARBE,WBBESCHICH,"
                        + " WBZUSTAND,WBSTK,WBMTR,WBART AS PHOTO FROM WBDAT WB RIGHT JOIN WASTAMM ON WBMANDANT=WAMANDANT AND WBART=WAART AND WBVAR=WAVAR"
                        + " WHERE WAMANDANT=:WAMANDANT AND WAKUNDNR='00000000' AND WADART=:WADART AND WADVAR=:WADVAR ";

                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwData["VAADART"].ToString();
                    or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwData["VAADVAR"].ToString();
                }
                if (option == "EQ")
                {
                    or1.CommandText += " AND (WBAENDDAT>=" + today + " OR WBNEUDAT>=" + today + ")";
                }
                //WBAENDDAT,WBNEUDAT
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("WBMANDANT");
                keylist.Add("WBWAKZ");
                keylist.Add("WBART");
                keylist.Add("WBVAR");
                keylist.Add("WBCOLORIT");
                keylist.Add("WBFARBE");
                keylist.Add("WBBESCHICH");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);

            }
            catch (Exception ex) { }
            return doc;
        }

        public XDocument QueryVAFARBEN(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "VAFARBEN";
            try
            {
                int ip = 0;
                List<string> Photos = new List<string>();
                //Photos.Add("P7");
                Photos.Add("P3");
                Photos.Add("P4");
                Photos.Add("P5");
                Photos.Add("P6");
                Photos.Add("P2");
                Photos.Add("P1");
                //Photos.Add("P8");
                //Photos.Add("P9");
                Photos.Add("P10");
                //Photos.Add("P11");
                or1 = OracleDB.CreateCommand();
                if (dwData == null)
                {
                    or1.CommandText = "SELECT ROWNUM AS MAINKEY, "
                    + "VAFMANDANT,VAFKOLL,VAFART,VAFFARBE,VAFBEZ,VAFFFARBE,VAFCOLORIT,VAFBESCHICH, "
                    + "Trim(VAFART)||Trim(VAFFARBE)||'.jpg'  AS PHOTO"
                    + " FROM VAFARBEN WHERE VAFMANDANT='00'";
                }
                else
                {
                    or1.CommandText = "SELECT ROWNUM AS MAINKEY, "
                        + "VAFMANDANT,VAFKOLL,VAFART,VAFFARBE,VAFBEZ,VAFFFARBE,VAFCOLORIT,VAFBESCHICH, "
                        + "Trim(VAFART)||Trim(VAFFARBE)  AS PHOTO"
                        + " FROM VAFARBEN  "
                        + " WHERE VAFMANDANT=:VAFMANDANT AND VAFKOLL=:VAFKOLL AND VAFART=:VAFART";
                    or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwData["VAAKOLL"].ToString();
                    or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();
                }
                if (option == "EQ")
                {
                    or1.CommandText += " AND (VAFAENDDAT>=" + today + " OR VAFNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["VAFBEZ"] = gb2312.Convert(vf["VAFBEZ"].ToString(), null, null, null);
                        vf["PHOTO"] = Photos[ip];
                        ip++;
                        if (ip > Photos.Count() - 1)
                        {
                            ip = 0;
                        }
                    }
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("VAFMANDANT");
                keylist.Add("VAFKOLL");
                keylist.Add("VAFART");
                keylist.Add("VAFFARBE");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex) { }
            return doc;
        }

        public XDocument QueryVAKOLL(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            OracleCommand or1;
            string table = "VAKOLL";
            try
            {

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT DISTINCT ROWNUM AS MAINKEY"
                + ",VAKMANDANT,VAKKOLL,VAKBEZ,VAKKOLL AS PHOTO"
                + " FROM VAKOLL "
                + " WHERE VAKMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (VAKAENDDAT>=" + today + " OR VAKNEUDAT>=" + today + ")";
                }
                //VAAAENDDAT,VAANEUDAT
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["VAKBEZ"] = gb2312.Convert(vf["VAKBEZ"].ToString(), null, null, null);
                    }
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("VAKMANDANT");
                keylist.Add("VAKKOLL");
                keylist.Add("VAKBEZ");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryVAART(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "VAART";
            try
            {
                int ip = 0;
                List<string> Photos = new List<string>();
                //Photos.Add("P7");
                Photos.Add("P3");
                Photos.Add("P4");
                Photos.Add("P5");
                Photos.Add("P6");
                Photos.Add("P2");
                Photos.Add("P1");
                //Photos.Add("P8");
                //Photos.Add("P9");
                Photos.Add("P10");
                //Photos.Add("P11");
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT DISTINCT ROWNUM AS MAINKEY"
                + ",VAAMANDANT,VAAKOLL,VAAART,VAAARTST,VAABEZ,VAABRTVON,VAAMEBRT,VAADART,VAADVAR,VAAART AS PHOTO"
                + " FROM VAART "
                + " WHERE VAAMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (VAAAENDDAT>=" + today + " OR VAANEUDAT>=" + today + ")";
                }
                //VAAAENDDAT,VAANEUDAT
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["VAABEZ"] = gb2312.Convert(vf["VAABEZ"].ToString(), null, null, null);

                        vf["PHOTO"] = Photos[ip];
                        ip++;
                        if (ip > Photos.Count() - 1)
                        {
                            ip = 0;
                        }
                    }
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("VAAMANDANT");
                keylist.Add("VAAKOLL");
                keylist.Add("VAAART");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryKDSTAMM(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "KDSTAMM";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,KDMANDANT,KDKUNDNR,KDKUNDNA,KDABCKL,KDNAME1,"
                    + "KDKNAME,KDNAME2,KDSTRASSE1,KDSTRASSE2,KDTEL,KDMAILADR, KDKUNDNA AS PHOTO FROM KDSTAMM WHERE KDMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (KDAEND>=" + today + " OR KDNEUD>=" + today + ")";
                }
                //KDAEND,KDNEUD
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["KDKUNDNA"] = gb2312.Convert(vf["KDKUNDNA"].ToString(), null, null, null);
                        vf["KDNAME1"] = gb2312.Convert(vf["KDNAME1"].ToString(), null, null, null);
                        vf["KDKNAME"] = gb2312.Convert(vf["KDKNAME"].ToString(), null, null, null);
                        vf["KDNAME2"] = gb2312.Convert(vf["KDNAME2"].ToString(), null, null, null);
                        vf["KDSTRASSE1"] = gb2312.Convert(vf["KDSTRASSE1"].ToString(), null, null, null);
                        vf["KDSTRASSE2"] = gb2312.Convert(vf["KDSTRASSE2"].ToString(), null, null, null);
                    }
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("KDMANDANT");
                keylist.Add("KDKUNDNR");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryVKPOS(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "VKPOS";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = " SELECT  ROWNUM AS MAINKEY,VKPMANDANT,VKPAUFKRS, VKPAUFLFD,VKPAUFPOS," +
                        "VKPNEUDAT,VKPKUNDNR"
                        + ",VKPKOLL,VKPART,VKPFARBE,VKPMENGE1,VKPMENGE2,VKPRESERV,VKPZUGET,VKPFREIGE,VKPGAUFBEST,VKPKOMMISS"
                        + ",VKPFAKT,VKPVERS,VKPEINGET,VKPOFFEN,VKPMEEH"
                        + ", VKPLIEFTERM,VKPART AS PHOTO"
                        + " FROM VKPOS WHERE VKPMANDANT='00' AND VKPSA<>'AJ' ";
                if (dwData != null)
                {
                    or1.CommandText = " SELECT  ROWNUM AS MAINKEY,VKPMANDANT,VKPAUFKRS, VKPAUFLFD,VKPAUFPOS," +
                        "VKPNEUDAT,VKPKUNDNR"
                        + ",VKPKOLL,VKPART,VKPFARBE,VKPMENGE1,VKPMENGE2,VKPRESERV,VKPZUGET,VKPFREIGE,VKPGAUFBEST,VKPKOMMISS"
                        + ",VKPFAKT,VKPVERS,VKPEINGET,VKPOFFEN,VKPMEEH"
                        + ", VKPLIEFTERM"
                        + " FROM VKPOS WHERE  VKPSA<>'AJ'  AND VKPMANDANT=:VKPMANDANT AND VKPKOLL=:VKPKOLL AND VKPART=:VKPART";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("VKPKOLL", OracleType.NVarChar).Value = dwData["VAAKOLL"].ToString();
                    or1.Parameters.Add("VKPART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();
                }

                if (option == "EQ")
                {
                    or1.CommandText += " AND (VKPNEUDAT>=" + today + " OR VKPPAENDDAT>=" + today + ")";
                }
                //VKPNEUDAT,VKPPAENDDAT
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("VKPMANDANT");
                keylist.Add("VKPAUFKRS");
                keylist.Add("VKPAUFLFD");
                keylist.Add("VKPAUFPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryVKKOPF(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "VKKOPF";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT ROWNUM AS MAINKEY,VKKMANDANT,VKKAUFKRS,VKKAUFLFD,VKKNEUDAT,VKKKUNDNR,VKKSACHBE "
                    + "from VKKOPF WHERE   VKKMANDANT='00' ";
                if (dwData != null)
                {
                    or1.CommandText = "SELECT ROWNUM AS MAINKEY,VKKMANDANT,VKKAUFKRS,VKKAUFLFD,VKKNEUDAT,VKKKUNDNR,VKKSACHBE,VKKKUNDNR AS PHOTO "
                        + "FROM VKKOPF VK RIGHT JOIN VKPOS  ON VKKMANDANT=VKPMANDANT AND VKKAUFKRS=VKPAUFKRS AND VKKAUFLFD=VKPAUFLFD "
                    + " WHERE   VKPSA<>'AJ'  AND VKPMANDANT=:VKPMANDANT AND VKPKOLL=:VKPKOLL AND VKPART=:VKPART";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("VKPKOLL", OracleType.NVarChar).Value = dwData["VAAKOLL"].ToString();
                    or1.Parameters.Add("VKPART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();
                }
                if (option == "EQ")
                {
                    //VKKAENDDAT,VKKNEUDAT
                    or1.CommandText += " AND (VKKAENDDAT>=" + today + " OR VKKNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("VKKMANDANT");
                keylist.Add("VKKAUFKRS");
                keylist.Add("VKKAUFLFD");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryWASTAMM(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "WASTAMM";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,WAMANDANT,WAART,WAVAR,WANEUB,WANEUD,WABEZ,WAFDDIM,WARWBRT,"
                + "WARGRQM,WARFDDIK,WARFDDIS,WABIND,WAFGRLFD,WAFFDDIK,WAFFDDIS,WADART,WADVAR " +
                    " FROM WASTAMM WHERE WAMANDANT='00' AND WAKUNDNR='        ' ";
                if (dwData != null)
                {

                    or1.CommandText = "SELECT  ROWNUM AS MAINKEY,WAMANDANT,WAART,WAVAR,WANEUB,WANEUD,WABEZ,WAFDDIM, WARGRQM"
                    + ",WAFFDDIK,WAFFDDIS,WABIND,WAFGRLFD ,"
                    + "WAFBRTL,WAFGRQM,WAFBEM,WAFILLER2,WADART,WADVAR,WAART AS PHOTO " +
                        " FROM WASTAMM "
                    + " WHERE WAMANDANT=:WAMANDANT AND WAKUNDNR='00000000' AND WADART=:WADART AND WADVAR=:WADVAR ";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwData["VAADART"].ToString();
                    or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwData["VAADVAR"].ToString();
                }

                if (option == "EQ")
                {
                    // WAAEND,WANEUD 
                    or1.CommandText += " AND (WAAEND>=" + today + " OR WANEUD>=" + today + ")";
                }

                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["WABEZ"] = gb2312.Convert(vf["WABEZ"].ToString(), null, null, null);
                    }
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("WAMANDANT");
                keylist.Add("WAART");
                keylist.Add("WAVAR");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryWAFARBEN(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "WAFARBEN";
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT ROWNUM AS MAINKEY,WAFMANDANT"
                + ",WAFART,WAFVAR,WAFZUART,WAFZUSATZ,WAFBEZ FROM WAFARBEN WHERE WAFMANDANT='00'";
                if (dwData != null)
                {
                    or1.CommandText = "SELECT ROWNUM AS MAINKEY,WAFMANDANT"
                        + ",WAFART,WAFVAR,WAFZUART,WAFZUSATZ,WAFBEZ,WAFART AS PHOTO FROM WAFARBEN WF RIGHT JOIN WASTAMM ON WAFART=WAART AND WAFVAR=WAVAR"
                        + " WHERE WAMANDANT=:WAMANDANT AND WAKUNDNR='00000000' AND WADART=:WADART AND WADVAR=:WADVAR ";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwData["VAADART"].ToString();
                    or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwData["VAADVAR"].ToString();
                }
                if (option == "EQ")
                {
                    // WAFAENDDAT,WAFNEUDAT
                    or1.CommandText += " AND (WAFAENDDAT>=" + today + " OR WAFNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    foreach (DataRow vf in Result.Tables[0].Rows)
                    {
                        vf["WAFBEZ"] = gb2312.Convert(vf["WAFBEZ"].ToString(), null, null, null);
                    }

                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("WAFMANDANT");
                keylist.Add("WAFART");
                keylist.Add("WAFVAR");
                keylist.Add("WAFZUART");
                keylist.Add("WAFZUSATZ");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryWDECK(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "WDECK";
            try
            {
                //SELECT WDSA,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDTYP,WDUPOS,WDWAKZ,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH,WDVAR,WDDAT,WDPRART,WDPRVAR FROM WDECK WHERE WDMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,WDMANDANT,WDSA,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDTYP,WDUPOS,"
                + "WDWAKZ,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH,WDVAR,WDDAT,WDPRART,WDPRVAR,WDART AS PHOTO"
                + " FROM WDECK WHERE WDMANDANT='00'";

                if (option == "EQ")
                {
                    // WAFAENDDAT,WAFNEUDAT
                    //or1.CommandText += " AND (WAFAENDDAT>=" + today + " OR WAFNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("WDMANDANT");
                keylist.Add("WDSA");
                keylist.Add("WDAUFKRS");
                keylist.Add("WDAUFLFD");
                keylist.Add("WDAUFPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryABAUFM(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "ABAUFM";
            try
            {
                //SELECT ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAAPOS,ABAVKAUFTYP,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS,ABAVKUPOS,ABAKUNDNR FROM ABAUFM WHERE ABAMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,"
                + "ABAMANDANT,ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAAPOS,ABAVKAUFTYP," +
                    "ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS,ABAVKUPOS,ABAKUNDNR,ABPAUFKRS AS PHOTO"
                    + " FROM ABAUFM WHERE ABAMANDANT='00'";

                if (option == "EQ")
                {
                    // ABAAENDDAT,ABANEUDAT
                    or1.CommandText += " AND (ABAAENDDAT>=" + today + " OR ABANEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("ABAMANDANT");
                keylist.Add("ABAAUFTYP");
                keylist.Add("ABAAUFKRS");
                keylist.Add("ABAAUFLFD");
                keylist.Add("ABAAUFPOS");
                keylist.Add("ABAAPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryABPOS(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "ABPOS";
            try
            {
                //SELECT ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,ABAAPOS,ABAVKAUFTYP,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS,ABAVKUPOS,ABAKUNDNR FROM ABAUFM WHERE ABAMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,ABPMANDANT,ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPWAKZ,ABPART,ABPVAR,ABPFARBE,ABPSOLLMENGE1,ABPSOLLMENGE2,ABPSOLLMENGE3,ABPSOLLMENGE4,ABPSOLLMENGE5,ABPSOLLMENGE6,ABPSOLLMENGE7,ABPSOLLMENGE8," +
                    "ABPLIEFDAT,ABPSTARTDAT, ABPNEUDAT FROM ABPOS WHERE ABPMANDANT='00'";
                if (dwData != null)
                {
                    or1.CommandText = "SELECT  ROWNUM AS MAINKEY,ABPMANDANT,ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPWAKZ,ABPART,ABPVAR,ABPFARBE,ABPSOLLMENGE1,ABPSOLLMENGE2,ABPSOLLMENGE3,ABPSOLLMENGE4,ABPSOLLMENGE5,ABPSOLLMENGE6,ABPSOLLMENGE7,ABPSOLLMENGE8,"
                       + "ABPLIEFDAT,ABPSTARTDAT, ABPNEUDAT,ABPART AS PHOTO FROM ABPOS AB RIGHT JOIN WASTAMM ON ABPMANDANT=WAMANDANT AND ABPART=WAART"
                      + " WHERE WAMANDANT=:WAMANDANT AND WAKUNDNR='00000000' AND WADART=:WADART AND WADVAR=:WADVAR ";

                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwData["VAADART"].ToString();
                    or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwData["VAADVAR"].ToString();

                }
                if (option == "EQ")
                {
                    // ABPAENDDAT,ABPNEUDAT
                    or1.CommandText += " AND (ABPAENDDAT>=" + today + " OR ABPNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("ABPMANDANT");
                keylist.Add("ABPAUFKRS");
                keylist.Add("ABPAUFLFD");
                keylist.Add("ABPAUFPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryABFOLGE(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "ABFOLGE";
            try
            {
                //SELECT ABFAUFKRS,ABFAUFLFD,ABFAUFPOS,ABFAFOLGE,ABFAGANG,ABFBZAGANG,ABFSOLLSTART,ABFSOLLDAT FROM ABFOLGE WHERE ABFMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,ABFMANDANT,ABFAUFKRS,ABFAUFLFD,ABFAUFPOS,"
                + "  ABFAFOLGE,ABFAGANG,ABFBZAGANG,ABFSOLLSTART,ABFSOLLDAT "
                    + ",ABFAUFKRS AS PHOTO FROM ABFOLGE WHERE ABFMANDANT='00'";
                if (option == "EQ")
                {
                    // ABPAENDDAT,ABPNEUDAT
                    or1.CommandText += " AND (ABFAENDDAT>=" + today + " OR ABFNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("ABFMANDANT");
                keylist.Add("ABFAUFKRS");
                keylist.Add("ABFAUFLFD");
                keylist.Add("ABFAUFPOS");
                keylist.Add("ABFAFOLGE");

                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryBAAUF(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "BAAUF";
            try
            {
                //SELECT BAAUFTYP,BAAUFKRS,BAAUFLFD,BAAUFPOS,BASA,BAPOS,BAAFOLGE,BADATVON,BAKART,BAKVAR,BAKFARBE
                //,BAMTR1,BAANZ1,BAMTR2,BAANZ2,BAMTR3,BAANZ3,BAMTR4,BAANZ4,BAMTR5,BAANZ5,BAMTR6,BAANZ6 ,BAMTR7,BAANZ7 FROM BAAUF WHERE BAMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT ROWNUM AS MAINKEY,BAMANDANT,BAAUFTYP,BAAUFKRS,BAAUFLFD,BAAUFPOS,BASA,BAPOS,BAAFOLGE,BADATVON,BAKART,BAKVAR,BAKFARBE"
                    + ",BAMTR1,BAANZ1,BAMTR2,BAANZ2,BAMTR3,BAANZ3,BAMTR4,BAANZ4,BAMTR5,BAANZ5,BAMTR6,BAANZ6 ,BAMTR7,BAANZ7 " +
                    " ,BAKART AS AS PHOTO FROM BAAUF WHERE BAMANDANT='00'";

                if (option == "EQ")
                {
                    or1.CommandText += " AND (BAAENDDAT>=" + today + " OR BANEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                keylist.Add("BAMANDANT");
                keylist.Add("BAAUFKRS");
                keylist.Add("BAAUFLFD");
                keylist.Add("BAAUFPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryGAAUF(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "GAAUF";
            try
            {
                //SELECT GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS,GAART,GAVAR,GAFARBE,GAKG1,GAKG2,GAKG3,GAKG4,GAKG5,GAKG6,GAKG7 FROM GAAUF WHERE GAMANDANT='00'

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,GAMANDANT,GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS,GAART,GAVAR,GAFARBE"
                + ",GAKG1,GAKG2,GAKG3,GAKG4,GAKG5,GAKG6,GAKG7,GAART AS PHOTO"
                    + "  FROM GAAUF WHERE GAMANDANT='00'";

                if (option == "EQ")
                {
                    or1.CommandText += " AND (GAAENDDAT>=" + today + " OR GANEUDAT>=" + today + ")";
                }

                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                // GAMANDANT,GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS
                keylist.Add("GAMANDANT");
                keylist.Add("GAAUFKRS");
                keylist.Add("GAAUFLFD");
                keylist.Add("GAAUFPOS");
                keylist.Add("GASA");
                keylist.Add("GAPOS");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryGSDAT(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "GSDAT";
            try
            {
                //SELECT GSART,GSVAR,GSHANDLNR,GSGARNBEZ,GSNUMART,GSGARNNR,GSFACH,GSRECHNUM,GSRECHNR FROM GSDAT WHERE GSMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT   ROWNUM AS MAINKEY, GSMANDANT,GSART,GSVAR,GSHANDLNR,GSGARNBEZ,GSNUMART"
                + ",GSGARNNR,GSFACH,GSRECHNUM,GSRECHNR,GSART AS PHOTO FROM GSDAT WHERE GSMANDANT='00'";

                if (option == "EQ")
                {
                    or1.CommandText += " AND (GSAENDDAT>=" + today + " OR GSNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                // GAMANDANT,GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS
                keylist.Add("GSMANDANT");
                keylist.Add("GSART");
                keylist.Add("GSVAR");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryGSCOLOR(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "GSCOLOR";
            try
            {
                //SELECT GSCART,GSCVAR,GSCFARBE, GSCBEZ FROM GSCOLOR WHERE GSCMANDANT='00'
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT ROWNUM AS MAINKEY,GSCMANDANT,GSCART,GSCVAR,GSCFARBE, GSCBEZ "
                + ",GSCART AS PHOTO FROM GSCOLOR WHERE GSCMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (GSCAENDDAT>=" + today + " OR GSCNEUDAT>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                // GAMANDANT,GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS
                keylist.Add("GSCMANDANT");
                keylist.Add("GSCART");
                keylist.Add("GSCVAR");
                keylist.Add("GSCFARBE");
                doc = DataToXml.Convert2XML(root, Result.Tables[0], key, keylist, true, SaveXML);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        public XDocument QueryLIEFDAT(string root, DataRow dwData, ref DataTable tb, string option = "LE", bool SaveXML = false)
        {
            DataSet Return = new DataSet();
            DataSet Result = new DataSet();
            XDocument doc = null;
            DataTable tbLocal = null;
            OracleCommand or1;
            string table = "LIEFDAT";
            try
            {
                //S LSAEND,LSNEUD 
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT  ROWNUM AS MAINKEY,LSMANDANT,LSLIEFNR,LSLIEFNA,LSNAME1,LSNAME2,LSSTRASSE1,LSLAND,LSPLZ,LSORT,LSTELEX,LSMAILADR "
                + ",LSLIEFNA AS PHOTO FROM LIEFDAT WHERE LSMANDANT='00'";
                if (option == "EQ")
                {
                    or1.CommandText += " AND (LSAEND>=" + today + " OR LSNEUD>=" + today + ")";
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    Result.Tables[0].TableName = table;
                    tb = Result.Tables[0].Copy();
                    CompressMainkey(Result.Tables[0]);
                }
                string key = table;
                ArrayList keylist = new ArrayList();
                // GAMANDANT,GAAUFKRS,GAAUFLFD,GAAUFPOS,GASA,GAPOS
                keylist.Add("LSMANDANT");
                keylist.Add("LSLIEFNR");
                doc = DataToXml.Convert2XML("PhoneDB", Result.Tables[0], key, keylist);

                Return.Merge(Result);
            }
            catch (Exception ex)
            {
            }
            return doc;
        }
        #endregion

        #region======A==============

        public DataSet QueryABARTE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1: 
                    or1.CommandText = "SELECT * FROM ABARTE WHERE  "
                    + "  ABEMANDANT=:ABEMANDANT AND ABEAUFKRS=:ABEAUFKRS AND ABEAUFLFD=:ABEAUFLFD AND ABEAUFPOS=:ABEAUFPOS AND ABEAFOLGE=:ABEAFOLGE"
                    + " AND ABEAEVOR=:ABEAEVOR AND ABEMODNR=:ABEMODNR AND ABEEINSTNR=:ABEEINSTNR";
                    or1.Parameters.Add("ABEMANDANT", OracleType.NVarChar).Value = dwData["ABEMANDANT"].ToString();
                    or1.Parameters.Add("ABEAUFKRS", OracleType.NVarChar).Value = dwData["ABEAUFKRS"].ToString();
                    or1.Parameters.Add("ABEAUFLFD", OracleType.NVarChar).Value = dwData["ABEAUFLFD"].ToString();
                    or1.Parameters.Add("ABEAUFPOS", OracleType.NVarChar).Value = dwData["ABEAUFPOS"].ToString();
                    or1.Parameters.Add("ABEAFOLGE", OracleType.NVarChar).Value = dwData["ABEAFOLGE"].ToString();
                    or1.Parameters.Add("ABEAEVOR", OracleType.NVarChar).Value = dwData["ABEAEVOR"].ToString();
                    or1.Parameters.Add("ABEMODNR", OracleType.NVarChar).Value = dwData["ABEMODNR"].ToString();
                    or1.Parameters.Add("ABEEINSTNR", OracleType.NVarChar).Value = dwData["ABEEINSTNR"].ToString(); 
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ABARTE WHERE  "
                    + "  ABEMANDANT=:ABEMANDANT AND ABEAUFKRS=:ABEAUFKRS AND ABEAUFLFD=:ABEAUFLFD AND ABEAUFPOS=:ABEAUFPOS";
                    or1.Parameters.Add("ABEMANDANT", OracleType.NVarChar).Value = dwData["ABEMANDANT"].ToString();
                    or1.Parameters.Add("ABEAUFKRS", OracleType.NVarChar).Value = dwData["ABEAUFKRS"].ToString();
                    or1.Parameters.Add("ABEAUFLFD", OracleType.NVarChar).Value = dwData["ABEAUFLFD"].ToString();
                    or1.Parameters.Add("ABEAUFPOS", OracleType.NVarChar).Value = dwData["ABEAUFPOS"].ToString();
                 
                    break; 
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABARTE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryABAUFM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ABAUFM WHERE  "
                    + "  ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = dwData["ABAAPOS"].ToString();
                    break;

                case 2:
                    or1.CommandText = "SELECT * FROM ABAUFM WHERE  "
                      + "  ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM ABAUFM WHERE  "
                    + "  ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM ABAUFM WHERE  "
                    + "  ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT * FROM ABAUFM WHERE  "
                    + "  ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABAUFM";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryICC_ABPOS_MAT(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MAT WHERE  "
                    + "  ABID=:ABID ";
                    or1.Parameters.Add("ABID", OracleType.NVarChar).Value = dwData["ABID"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MAT WHERE  "
                      + "  ABEND=:ABEND  ORDER BY ABPART,ABPVAR,ABPFARBE,KRS,LFD";
                    or1.Parameters.Add("ABEND", OracleType.NVarChar).Value = dwData["ABEND"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MAT WHERE  "
                    + "  ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPART=:ABPART";
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 4:
                    string sections = dwData["ARTDES"].ToString().Trim();
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MAT WHERE  "
                      + "  ABEND=:ABEND AND KOLL=:KOLL AND SECTION IN (" + sections + ") ORDER BY ABPART,ABPVAR,ABPFARBE,KRS,LFD";
                    or1.Parameters.Add("ABEND", OracleType.NVarChar).Value = dwData["ABEND"].ToString();
                    or1.Parameters.Add("KOLL", OracleType.NVarChar).Value = dwData["KOLL"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_ABPOS_MAT";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryICC_ABAUFM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT A.*,  LSSTRASSE1,LSAPNA1,LSAPTEL1"
                    + " FROM (SELECT EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE,ABPLIEFNR,MU.ABPART AS ABPART,MAX(MU.FSABEZ) AS FSABEZ"
                        + ",ABPAUFKRS,ABPAUFLFD FROM EKPOS"
                        + " JOIN ICC_ABAUFM MU  ON EKPAUFKRS=ABAAUFKRS AND EKPAUFLFD=ABAAUFLFD AND EKPAUFPOS=ABAAUFPOS"
                        + " JOIN ABPOS P ON MU.ABAVKAUFKRS=P.ABPAUFKRS AND MU.ABAVKAUFLFD=P.ABPAUFLFD  AND MU.ABAVKAUFPOS=P.ABPAUFPOS"
                        + " WHERE EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD AND EKPSA='PO' "
                        + " GROUP BY  EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,ABPAUFKRS,ABPAUFLFD,MU.ABPART,ABPLIEFNR) A"
                    + "  JOIN LIEFDAT S ON A.ABPLIEFNR=S.LSLIEFNR";
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "  SELECT ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE"
                        + ",SUM(ABARESMG)AS ABARESMG, SUM(ABAQTYALLOCATE) AS ABAQTYALLOCATE,SUM(ABAQTYRECEIVED) AS ABAQTYRECEIVED,MAX(WAFGRLFD) AS WAFGRLFD,MAX(WAUEBM) AS WAUEBM"
                        + " FROM INTEX.ICC_ABAUFM M WHERE ABAMANDANT=:ABAMANDANT AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE"
                        + " AND ABAGROE=:ABAGROE "
                        + " GROUP BY ABAAUFTYP,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 7:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                case 8:
                    or1.CommandText = " SELECT M.* FROM INTEX.MDECK R"
                        + " JOIN ICC_ABAUFM M  ON R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD AND R.MDAUFPOS=M.ABAVKAUFPOS AND TRIM(R.MDRPOS)=TRIM(M.ABAVKUPOS)"
                        + " WHERE MDMANDANT=:MDMANDANT  AND MDTYP=:MDTYP AND MDMAT=:MDMAT AND MDVAR=:MDVAR";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    or1.Parameters.Add("MDMAT", OracleType.NVarChar).Value = dwData["MDMAT"].ToString();
                    or1.Parameters.Add("MDVAR", OracleType.NVarChar).Value = dwData["MDVAR"].ToString();
                    break;
                case 9:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 91:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND FSSZUSCHN=:FSSZUSCHN AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    break;
                case 10:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 101:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE"
                        + "  AND FSSZUSCHN=:FSSZUSCHN  AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    break;
                case 11:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwData["ABAAUFPOS"].ToString();
                    break;
                case 12:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 13:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 14:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 15:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND SUBSTR(FSSZUSCHN||' ',1,1)=:FSSZUSCHN AND   ABAAUFTYP='N' AND M.ABPART=:ABPART AND M.ABAART=:ABAART"
                        +" AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 151:
                    string ABPART = dwData["ABPART"].ToString();
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND FSSZUSCHN=:FSSZUSCHN AND   ABAAUFTYP='N' AND M.ABPART in (" + ABPART + ") AND M.ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    //or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 16:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS"
                    + " AND   ABAART=:ABAART and ABAVAR=:ABAVAR  and ABAFARBE=:ABAFARBE and ABAGROE=:ABAGROE ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 17:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABPART=P.ABPART AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD<=:ABPSPGRD"
                        + " WHERE ABAAUFTYP='N' AND SUBSTR(FSSZUSCHN||' ',1,1)=:FSSZUSCHN AND ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE"
                        + " AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF  AND M.ABPART=:ABPART"
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABACOLORREF", OracleType.NVarChar).Value = dwData["ABACOLORREF"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["FSSZUSCHN"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    break;
                case 18:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 19:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND ABPSPGRD>:ABPSPGRD"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND   ABAAUFTYP='N' AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABACOLORREF=:ABACOLORREF"
                        + " AND ABAVKAUFKRS=:ABAVKAUFKRS AND  ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwData["ABAVKAUFPOS"].ToString();
                    break;
                case 20:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " JOIN ABPOS P ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS AND  ABPERLKZ=' ' "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE "
                        + " AND M.ABPART=:ABPART "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 21:
                    or1.CommandText = "SELECT DISTINCT ABPART,ABAART,FSSZUSCHN FROM ICC_ABAUFM M "
                            + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwData["ABAAUFKRS"].ToString();
                    or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwData["ABAAUFLFD"].ToString();
                    break;
                case 23:
                    or1.CommandText = " SELECT M.* FROM FDECK M "
                        + " JOIN ABPOS P ON M.FDAUFKRS=P.ABPAUFKRS AND M.FDAUFLFD=P.ABPAUFLFD AND M.FDAUFPOS=P.ABPAUFPOS "
                        + " WHERE FDMANDANT=:FDMANDANT  AND FDART=:FDART AND FDVAR=:FDVAR AND FDFARBE=:FDFARBE AND FDGROE=:FDGROE "
                        + " AND ABPART=:ABPART "
                        + " ORDER BY ABAQTYRESERVE,ABAQTYALLOCATE,LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    or1.Parameters.Add("FDVAR", OracleType.NVarChar).Value = dwData["FDVAR"].ToString();
                    or1.Parameters.Add("FDFARBE", OracleType.NVarChar).Value = dwData["FDFARBE"].ToString();
                    or1.Parameters.Add("FDGROE", OracleType.NVarChar).Value = dwData["FDGROE"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 24:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD "
                    + " AND   ABAART=:ABAART  ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    break;
                case 25:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();                 
                    break;
                case 26:
                    or1.CommandText = " SELECT M.* FROM ICC_ABAUFM M "
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABPART=:ABPART "                       
                        + " ORDER BY LSLIEFNA,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();      
                    break;
                case 99:
                    or1.CommandText = "SELECT * FROM ICC_ABAUFM  "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD  ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_ABAUFM";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryABFOLGE(string client, string krs, string lfd, string pos)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM ABFOLGE WHERE  "
            + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD AND ABFAUFPOS=:ABFAUFPOS";
            or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = krs;
            or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = lfd;
            or1.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = pos;
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABFOLGE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryICC_ABPOS_MCO(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            string ART = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MCO  WHERE ABCOID=: ABCOID";
                    or1.Parameters.Add("ABCOID", OracleType.NVarChar).Value = dwData["ABCOID"].ToString();
                    break;
                case 2:
                    ART = dwData["ART"].ToString().Trim();
                    or1.CommandText = "SELECT * FROM ICC_ABPOS_MCO "
                        + " WHERE ART LIKE '%" + ART + "%'"
                        + " ORDER BY ART,FARBE,KRS,LFD ";
                    /*
                    + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD AND ABFAUFPOS=:ABFAUFPOS";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    or1.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = dwData["ABFAUFPOS"].ToString();*/
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_ABPOS_MCO";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryABFOLGE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ABFOLGE WHERE  "
                    + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD AND ABFAUFPOS=:ABFAUFPOS";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    or1.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = dwData["ABFAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ABFOLGE WHERE  "
                        + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ABFOLGE WHERE  "
                     + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD AND ABFAUFPOS=:ABFAUFPOS AND ABFAFOLGE=:ABFAFOLGE";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    or1.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = dwData["ABFAUFPOS"].ToString();
                    or1.Parameters.Add("ABFAFOLGE", OracleType.NVarChar).Value = dwData["ABFAFOLGE"];
                    break;
                case 4:
                    or1.CommandText = "SELECT ABFMANDANT,ABFLIEFNR FROM ABFOLGE WHERE  "
                        + "  ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABFOLGE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryABKOPF(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE  "
                    + "  ABKMANDANT=:ABKMANDANT AND ABKAUFKRS=:ABKAUFKRS AND ABKAUFLFD=:ABKAUFLFD";
                    or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"].ToString();
                    or1.Parameters.Add("ABKAUFKRS", OracleType.NVarChar).Value = dwData["ABKAUFKRS"].ToString();
                    or1.Parameters.Add("ABKAUFLFD", OracleType.NVarChar).Value = dwData["ABKAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT DISTINCT MAX(ABPSPGRD) AS ABKSPGRD,MAX(ABPGESSTA) AS ABKGESSTA, MAX(ABPLIEFDAT) AS ABKLIEFDAT,ABKMANDANT, ABKAUFKRS,ABKAUFLFD,"
                    + "MAX(ABPART) AS ABPART,MAX(FSABEZ) AS FSABEZ,MAX(LSLIEFNA) AS EXTPRODUCER,MAX(LSNAME1) AS EXTFTYNAME,MAX(ABPLIEFNR) AS ABPLIEFNR,ABPANRKR"
                    + ",ABPALFDNR FROM ABKOPF K"
                            + " RIGHT JOIN ABPOS P ON ABKAUFKRS=ABPAUFKRS AND ABKAUFLFD=ABPAUFLFD"
                            + " LEFT JOIN FSSTAMM M ON ABPART=FSART "
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                            + " WHERE ABPMANDANT=:ABPMANDANT AND ABPSPGRD=:ABPSPGRD AND AND ABPERLKZ=' '"
                            + " GROUP BY ABKMANDANT,ABKAUFKRS,ABKAUFLFD,ABPANRKR,ABPALFDNR";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABPSPGRD"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE ABKMANDANT=:ABKMANDANT AND SUBSTR(ABKKDAUFTNR,1,8)=:ABKKDAUFTNR";
                    or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"].ToString();
                    or1.Parameters.Add("ABKKDAUFTNR", OracleType.NVarChar).Value = dwData["ABKKDAUFTNR"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT K.* FROM ABKOPF K "
                        + "JOIN ABPOS P ON K.ABKAUFKRS=P.ABPAUFKRS AND K.ABKAUFLFD=P.ABPAUFLFD"
                        + " JOIN FSSTAMM M ON P.ABPART=M.FSART"
                        + " WHERE FSMANDANT=:FSMANDANT AND M.FSART=:FSART";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT MAX(ABPSPGRD) AS ABKSPGRD,MAX(ABPGESSTA) AS ABKGESSTA, MAX(ABPLIEFDAT) AS ABKLIEFDAT,ABKMANDANT, ABKAUFKRS,ABKAUFLFD,"
                    + "MAX(ABPART) AS ABPART,MAX(FSABEZ) AS FSABEZ,MAX(LSLIEFNA) AS EXTPRODUCER,MAX(LSNAME1) AS EXTFTYNAME,MAX(ABPLIEFNR) AS ABPLIEFNR,ABPANRKR"
                    + ",ABPALFDNR FROM ABKOPF K"
                            + " RIGHT JOIN ABPOS P ON ABKAUFKRS=ABPAUFKRS AND ABKAUFLFD=ABPAUFLFD"
                            + " LEFT JOIN FSSTAMM M ON ABPART=FSART "
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                            + " WHERE ABPMANDANT=:ABPMANDANT AND ABPERLKZ=' '"
                            + " GROUP BY ABKMANDANT,ABKAUFKRS,ABKAUFLFD,ABPANRKR,ABPALFDNR";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABKOPF";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryABPOS(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPAUFPOS=:ABPAUFPOS";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwData["ABPAUFPOS"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT  AND ABPERLKZ=' '"
                    + "   ORDER BY ABPAUFKRS,ABPAUFLFD,ABPAUFPOS";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS, ABPART,ABPVAR,ABPFARBE,ABPBESCHICH,"
                        + " ABPSOLLMENGE1*0.01 AS ABPSOLLMENGE1,ABPSOLLMENGE5*0.01 AS ABPSOLLMENGE5,ABPSOLLMENGE7*0.01 AS ABPSOLLMENGE7,"
                        + " ABPSTARTDAT,ABPLIEFDAT,ABABEM1,ABABEM2 FROM ABPOS P, ABAUFM MU WHERE "
                        + " ABPMANDANT=:ABPMANDANT  AND ABPERLKZ=' ' AND ABAMANDANT=ABPMANDANT"
                        + " AND ABPAUFKRS=ABAAUFKRS"
                        + " AND ABPAUFLFD=ABAAUFLFD"
                        + " AND ABPAUFPOS=ABAAUFPOS"
                        + " AND ABAAPOS='0001' AND ABPAUFART='VA' AND ROWNUM<200"
                        + " ORDER BY ABPAUFKRS,ABPAUFLFD,ABPAUFPOS ";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                case 5:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS, ABPART,ABPVAR,ABPFARBE,ABPGROE,"
                        + " ABPSOLLMENGE7,"
                        + " ABPSTARTDAT,ABPLIEFDAT,ABABEM1,ABABEM2 FROM ABPOS P, ABAUFM MU WHERE "
                        + " ABPMANDANT=:ABPMANDANT  AND ABPERLKZ=' ' AND ABAMANDANT=ABPMANDANT"
                        + " AND ABPAUFKRS=ABAAUFKRS"
                        + " AND ABPAUFLFD=ABAAUFLFD"
                        + " AND ABPAUFPOS=ABAAUFPOS"
                        + " AND ABAAPOS='0001' AND ABPAUFART='VA' AND ROWNUM<200"
                        + " ORDER BY ABPAUFKRS,ABPAUFLFD,ABPAUFPOS ";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                case 8:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT P.*,FSABEZ,FSFFBEZ FROM ABPOS P RIGHT JOIN ICC_ABAUFM M "
                        + " ON ABPAUFKRS=M.ABAVKAUFKRS AND ABPAUFLFD=M.ABAVKAUFLFD AND ABPAUFPOS=M.ABAVKAUFPOS "
                        + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 9:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT M.FSSZUSCHN,ABPSPGRD,M.ABPART,M.ABPFARBE FROM ICC_ABAUFM M JOIN ABPOS P"
                        + " ON M.ABAVKAUFKRS=P.ABPAUFKRS AND M.ABAVKAUFLFD=P.ABPAUFLFD AND M.ABAVKAUFPOS=P.ABPAUFPOS"
                        + " JOIN FSSTUELI X ON M.ABPART=FSSART  AND ABAART=FSSMART  AND ABAFARBE=FSSMFARBE "
                         + " AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                case 10:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT * FROM ABPOS   "
                        + " WHERE ABPMANDANT=:ABPMANDANT  AND ABPART=:ABPART";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 11:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "   SELECT DISTINCT  P.ABPAUFKRS,P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPFARBE,P.ABPGROE"
                    + " FROM FSSTUELI S JOIN FDECK FD ON FDART=FSSMART "
                    + " JOIN WDECK ON WDART=FSSMART "
                    + " JOIN ABPOS P ON ABPAUFKRS=WDAUFKRS AND ABPAUFLFD=WDAUFLFD AND ABPAUFPOS=WDAUFPOS"
                        + " WHERE FSSMANDANT=:FSSMANDANT  AND FSSMART=:FSSMART";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    break;
                case 12:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "   SELECT DISTINCT  P.ABPAUFKRS,P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPFARBE,P.ABPGROE"
                    + " FROM FSSTUELI S JOIN FDECK FD ON FDART=FSSMART "
                    + " JOIN FDECK ON FDART=FSSMART "
                    + " JOIN ABPOS P ON ABPAUFKRS=FDAUFKRS AND ABPAUFLFD=FDAUFLFD AND ABPAUFPOS=FDAUFPOS"
                        + " WHERE FSSMANDANT=:FSSMANDANT  AND FSSMART=:FSSMART";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    break;
                case 13:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT P.*,FSABEZ,FSFFBEZ FROM ABPOS P RIGHT JOIN ICC_ABAUFM M "
                        + " ON ABPAUFKRS=M.ABAVKAUFKRS AND ABPAUFLFD=M.ABAVKAUFLFD AND ABPAUFPOS=M.ABAVKAUFPOS "
                        //+ " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABPSPGRD=:ABPSPGRD";
                        + " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    //or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString(); 
                    break;
                case 14:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE FROM ABPOS   "
                        + " WHERE ABPMANDANT=:ABPMANDANT  AND ABPART=:ABPART AND ABPERLKZ=' '";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    break;
                case 15:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT P.*,FSABEZ,FSFFBEZ FROM ABPOS P RIGHT JOIN ICC_ABAUFM M "
                        + " ON ABPAUFKRS=M.ABAVKAUFKRS AND ABPAUFLFD=M.ABAVKAUFLFD AND ABPAUFPOS=M.ABAVKAUFPOS "
                        //+ " WHERE ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE AND ABPSPGRD=:ABPSPGRD";
                        + " WHERE P.ABPART=:ABPART AND ABAMANDANT=:ABAMANDANT  AND ABAART=:ABAART AND ABAVAR=:ABAVAR AND ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    //or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString(); 
                    break;
                case 16:
                    string ABPART = dwData["ABPART"].ToString().Trim();
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT P.*,FSABEZ,FSFFBEZ FROM ABPOS P RIGHT JOIN ICC_ABAUFM M "
                        + " ON ABPAUFKRS=M.ABAVKAUFKRS AND ABPAUFLFD=M.ABAVKAUFLFD AND ABPAUFPOS=M.ABAVKAUFPOS "
                        + " AND M.ABPART LIKE '" + ABPART + "%'"
                        + " WHERE ABAMANDANT=:ABAMANDANT";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    break;
                case 17:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT ABPAUFKRS||ABPAUFLFD AS ABPAUF,ABPMANDANT,ABPAUFKRS,ABPAUFLFD FROM ABPOS P  "
                        + " WHERE ABPMANDANT=:ABPMANDANT"
                          + " AND ABPART LIKE '" + dwData["ABPART"].ToString().Trim() + "%'";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                case 18:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT DISTINCT P.*,FSABEZ,FSFFBEZ,FSPROGRP AS ABPKPROGRP,FSARTGRP AS ABPKARTGRP FROM ABPOS P "
                    + " JOIN FSSTAMM M  ON ABPART=M.FSART "
                    + " JOIN FSFARBEN F  ON ABPART=F.FSFART AND ABPFARBE=F.FSFFARBE"
                    + " WHERE  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD"
                    + " ORDER BY ABPAUFPOS";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
                case 19:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT MAX(ABPAUFPOS) AS ABPAUFPOS FROM ABPOS  "
                   + " WHERE  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
                case 99:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
                default:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryICC_ABPOSFS(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_ABPOSFS WHERE  "
                    + "  KRS=:KRS AND LFD=:LFD AND FARBE=:FARBE";
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"].ToString();
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"].ToString();
                    or1.Parameters.Add("FARBE", OracleType.NVarChar).Value = dwData["FARBE"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_ABPOSFS WHERE DELDAT>'20130808' ";
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ICC_ABPOSFS WHERE  "
                    + "  KRS=:KRS AND LFD=:LFD";
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"].ToString();
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_ABPOSFS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryABPOS(string client, string krs, string lfd, string pos = null)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            if (pos != null)
            {
                or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPAUFPOS=:ABPAUFPOS";
                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = client;
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = krs;
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = lfd;
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = pos;
            }
            else
            {
                or1.CommandText = "SELECT * FROM ABPOS WHERE  "
             + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD ";
                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = client;
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = krs;
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = lfd;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryABPR(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ABPR WHERE  "
                    + "  ARMANDANT=:ARMANDANT AND ARAUFKRS=:ARAUFKRS AND ARAUFLFD=:ARAUFLFD AND ARAUFPOS=:ARAUFPOS";
                    or1.Parameters.Add("ARMANDANT", OracleType.NVarChar).Value = dwData["ARMANDANT"].ToString();
                    or1.Parameters.Add("ARAUFKRS", OracleType.NVarChar).Value = dwData["ARAUFKRS"].ToString();
                    or1.Parameters.Add("ARAUFLFD", OracleType.NVarChar).Value = dwData["ARAUFLFD"].ToString();
                    or1.Parameters.Add("ARAUFPOS", OracleType.NVarChar).Value = dwData["ARAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ABPR WHERE  "
                    + "  ARMANDANT=:ARMANDANT AND ARAUFKRS=:ARAUFKRS AND ARAUFLFD=:ARAUFLFD AND ARAUFPOS=:ARAUFPOS";
                    or1.Parameters.Add("ARMANDANT", OracleType.NVarChar).Value = dwData["ARMANDANT"].ToString();
                    or1.Parameters.Add("ARAUFKRS", OracleType.NVarChar).Value = dwData["ARAUFKRS"].ToString();
                    or1.Parameters.Add("ARAUFLFD", OracleType.NVarChar).Value = dwData["ARAUFLFD"].ToString();
                    or1.Parameters.Add("ARAUFPOS", OracleType.NVarChar).Value = dwData["ARAUFPOS"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM ABPR WHERE  "
                    + "  ARMANDANT=:ARMANDANT AND ARAUFKRS=:ARAUFKRS AND ARAUFLFD=:ARAUFLFD";
                    or1.Parameters.Add("ARMANDANT", OracleType.NVarChar).Value = dwData["ARMANDANT"].ToString();
                    or1.Parameters.Add("ARAUFKRS", OracleType.NVarChar).Value = dwData["ARAUFKRS"].ToString();
                    or1.Parameters.Add("ARAUFLFD", OracleType.NVarChar).Value = dwData["ARAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABPR";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryAPZUORD(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM APZUORD WHERE  "
+ "  APZMANDANT=:APZMANDANT AND APZART=:APZART AND APZVAR=:APZVAR AND APZANRKRS=:APZANRKRS AND "
+ "APZALFDNR=:APZALFDNR AND APZSTUFE=:APZSTUFE";
                    or1.Parameters.Add("APZMANDANT", OracleType.NVarChar).Value = dwData["APZMANDANT"].ToString();
                    or1.Parameters.Add("APZART", OracleType.NVarChar).Value = dwData["APZART"].ToString();
                    or1.Parameters.Add("APZVAR", OracleType.NVarChar).Value = dwData["APZVAR"].ToString();
                    or1.Parameters.Add("APZANRKRS", OracleType.NVarChar).Value = dwData["APZANRKRS"].ToString(); ;
                    or1.Parameters.Add("APZALFDNR", OracleType.NVarChar).Value = dwData["APZALFDNR"].ToString();
                    or1.Parameters.Add("APZSTUFE", OracleType.NVarChar).Value = dwData["APZSTUFE"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT DISTINCT P.* FROM APZUORD P"
                        +" RIGHT JOIN WDECK ON APZMANDANT=WDMANDANT AND WDART=APZART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString(); 
                    break;
                case 3:
                    or1.CommandText = "SELECT DISTINCT P.* FROM APZUORD P "
                        +"RIGHT JOIN WASTKE ON WAKKART=APZART "
                        + " RIGHT JOIN WDECK ON WAKMANDANT=WDMANDANT AND WDART=WAKART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT P.* FROM APZUORD P "
                        + "RIGHT JOIN WASTGA ON WAGGART=APZART "
                        + " RIGHT JOIN WDECK ON WAGMANDANT=WDMANDANT AND WAGART=WDART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT P.* FROM APZUORD P "
                        + "RIGHT JOIN BASTGA ON BAGGART=APZART "                        
                        + "RIGHT JOIN WASTKE ON WAKKART=BAGART "
                        + " RIGHT JOIN WDECK ON WAKMANDANT=WDMANDANT AND WAKART=WDART"                        
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;

            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "APZUORD";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryAPARTK(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM APARTK WHERE  "
                        + "  APAKMANDANT=:APAKMANDANT  AND APAKANRKRS=:APAKANRKRS AND APAKALFDNR=:APAKALFDNR ";
                    or1.Parameters.Add("APAKMANDANT", OracleType.NVarChar).Value = dwData["APAKMANDANT"].ToString();
                    or1.Parameters.Add("APAKANRKRS", OracleType.NVarChar).Value = dwData["APAKANRKRS"].ToString(); 
                    or1.Parameters.Add("APAKALFDNR", OracleType.NVarChar).Value = dwData["APAKALFDNR"].ToString();                    
                    break; 
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "APARTK";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        
        public DataSet QueryAPFOLGE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT P.* FROM APFOLGE P "
                        + "  WHERE APFMANDANT=:APFMANDANT AND APFANRKRS=:APFANRKRS AND APFALFDNR=:APFALFDNR";
                    or1.Parameters.Add("APFMANDANT", OracleType.NVarChar).Value = dwData["APFMANDANT"];
                    or1.Parameters.Add("APFANRKRS", OracleType.NVarChar).Value = dwData["APFANRKRS"];
                    or1.Parameters.Add("APFALFDNR", OracleType.NVarChar).Value = dwData["APFALFDNR"];
                    break;
                case 2:
                    or1.CommandText = "SELECT APFMANDANT,APFANRKRS,APFALFDNR,APFAFOLGE,APFAGANG,APFKSTKRS,APFKST,APFMTYP"
                    + ",KSZLIEFNR,KSZLO,KSZLB FROM APFOLGE P LEFT JOIN KSTAGZUO k "
                    + " ON P.APFKSTKRS=KSZKSTKRS AND APFKST=KSZKST AND APFAGANG=KSZAGANG "
                    + "  WHERE APFMANDANT=:APFMANDANT AND APFANRKRS=:APFANRKRS AND APFALFDNR=:APFALFDNR";
                    or1.Parameters.Add("APFMANDANT", OracleType.NVarChar).Value = dwData["APFMANDANT"];
                    or1.Parameters.Add("APFANRKRS", OracleType.NVarChar).Value = dwData["APFANRKRS"];
                    or1.Parameters.Add("APFALFDNR", OracleType.NVarChar).Value = dwData["APFALFDNR"];
                    break;
                case 3:
                    or1.CommandText = "SELECT APFMANDANT,APFANRKRS,APFALFDNR,APFAFOLGE,APFAGANG,APFKSTKRS,APFKST,APFMTYP"
                    + ",KSZLIEFNR,KSZLO,KSZLB,KSZLP FROM APFOLGE P LEFT JOIN KSTAGZUO k "
                    + " ON P.APFKSTKRS=KSZKSTKRS AND APFKST=KSZKST AND APFAGANG=KSZAGANG "
                    + "  WHERE APFMANDANT=:APFMANDANT ";
                    or1.Parameters.Add("APFMANDANT", OracleType.NVarChar).Value = dwData["APFMANDANT"];
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT APFMANDANT,APFANRKRS,APFALFDNR,APFAFOLGE,APFAGANG,APFKSTKRS,APFKST,APFMTYP,"
                    +"APFPARALKZ,APFBASMGE,APFME,APFRUECKKZ,APFKENNUNG,APFZUSATZ1,APFZUSATZ2,APFZUSATZ3,APFZUSATZ4,APFZUSATZ5,"
                    +"APFZUSTAND,APFFERTIG,APFMATABR,APFDOMPART,APFPRUEFANW,APFPROBE,APFANRKRS,APFALFDNR,APFAFOLGE,APFAEVOR,APFEINSTKA"
                    + ",KSZLIEFNR,KSZLO,KSZLB,KSZLP,KSZMANUELKZ,KSZLAGPLKZ,KSZAUFBKZ,AMNRKRS,AMLFDNR,AMPOS FROM APFOLGE P"
                    +" LEFT JOIN KSTAGZUO k ON P.APFKSTKRS=KSZKSTKRS AND APFKST=KSZKST AND APFAGANG=KSZAGANG "
                    + " LEFT JOIN AMSTAMM M ON P.APFKSTKRS=AMKSTKRS AND APFKST=AMKST AND  APFMTYP=AMTYP AND AMSTDVAR='J' "
                    + " WHERE APFMANDANT=:APFMANDANT AND APFANRKRS=:APFANRKRS AND APFALFDNR=:APFALFDNR";
                    or1.Parameters.Add("APFMANDANT", OracleType.NVarChar).Value = dwData["APFMANDANT"].ToString();
                    or1.Parameters.Add("APFANRKRS", OracleType.NVarChar).Value = dwData["APFANRKRS"].ToString();
                    or1.Parameters.Add("APFALFDNR", OracleType.NVarChar).Value = dwData["APFALFDNR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "APFOLGE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryAPFOLGE(string client, string krs, string lfd)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();

            or1.CommandText = "SELECT P.*,KSZLIEFNR,KSZLO,KSZLB FROM APFOLGE P LEFT JOIN KSTAGZUO k "
                + " ON P.APFKSTKRS=KSZKSTKRS AND APFKST=KSZKST AND APFAGANG=KSZAGANG "
            + "  WHERE APFMANDANT=:APFMANDANT AND APFANRKRS=:APFANRKRS AND APFALFDNR=:APFALFDNR";
            or1.Parameters.Add("APFMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("APFANRKRS", OracleType.NVarChar).Value = krs;
            or1.Parameters.Add("APFALFDNR", OracleType.NVarChar).Value = lfd;
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "APFOLGE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryAPKOPF(string apkrs, string apdnr)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM APKOPF WHERE  "
            + "  APKMANDANT='00' AND APKANRKRS=:APKANRKRS AND APKALFDNR=:APKALFDNR";

            or1.Parameters.Add("APKANRKRS", OracleType.NVarChar).Value = apkrs;
            or1.Parameters.Add("APKALFDNR", OracleType.NVarChar).Value = apdnr;

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "APKOPF";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        #endregion
        #region======B==============
        public DataSet QueryBAAUF(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM  BAAUF"
                        + " WHERE "
                        + " BAMANDANT=:BAMANDANT AND BAAUFTYP=:BAAUFTYP AND BAAUFKRS=:BAAUFKRS AND BAAUFLFD=:BAAUFLFD AND BAAUFPOS=:BAAUFPOS"
                        + " AND BASA=:BASA AND BAPOS=:BAPOS";
                    or1.Parameters.Add("BAMANDANT", OracleType.NVarChar).Value = dwData["BAMANDANT"].ToString();
                    or1.Parameters.Add("BAAUFTYP", OracleType.NVarChar).Value = dwData["BAAUFTYP"].ToString();
                    or1.Parameters.Add("BAAUFKRS", OracleType.NVarChar).Value = dwData["BAAUFKRS"].ToString();
                    or1.Parameters.Add("BAAUFLFD", OracleType.NVarChar).Value = dwData["BAAUFLFD"].ToString();
                    or1.Parameters.Add("BAAUFPOS", OracleType.NVarChar).Value = dwData["BAAUFPOS"].ToString();
                    or1.Parameters.Add("BASA", OracleType.NVarChar).Value = dwData["BASA"].ToString();
                    or1.Parameters.Add("BAPOS", OracleType.NVarChar).Value = dwData["BAPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM  BAAUF"
                        + " WHERE "
                        + " BAMANDANT=:BAMANDANT AND BAAUFTYP=:BAAUFTYP AND BAAUFKRS=:BAAUFKRS AND BAAUFLFD=:BAAUFLFD AND BAAUFPOS=:BAAUFPOS"
        ;
                    or1.Parameters.Add("BAMANDANT", OracleType.NVarChar).Value = dwData["BAMANDANT"].ToString();
                    or1.Parameters.Add("BAAUFTYP", OracleType.NVarChar).Value = dwData["BAAUFTYP"].ToString();
                    or1.Parameters.Add("BAAUFKRS", OracleType.NVarChar).Value = dwData["BAAUFKRS"].ToString();
                    or1.Parameters.Add("BAAUFLFD", OracleType.NVarChar).Value = dwData["BAAUFLFD"].ToString();
                    or1.Parameters.Add("BAAUFPOS", OracleType.NVarChar).Value = dwData["BAAUFPOS"].ToString();
                
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM  BAAUF"
                        + " WHERE "
                        + " BAMANDANT=:BAMANDANT  AND BAAUFKRS=:BAAUFKRS AND BAAUFLFD=:BAAUFLFD AND BAAUFPOS=:BAAUFPOS"
                        + "  AND BAPOS=:BAPOS";
                    or1.Parameters.Add("BAMANDANT", OracleType.NVarChar).Value = dwData["BAMANDANT"].ToString();
                    or1.Parameters.Add("BAAUFKRS", OracleType.NVarChar).Value = dwData["BAAUFKRS"].ToString();
                    or1.Parameters.Add("BAAUFLFD", OracleType.NVarChar).Value = dwData["BAAUFLFD"].ToString();
                    or1.Parameters.Add("BAAUFPOS", OracleType.NVarChar).Value = dwData["BAAUFPOS"].ToString();
                    or1.Parameters.Add("BAPOS", OracleType.NVarChar).Value = dwData["BAPOS"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BAAUF";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBABST(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM  BABST"
                        + " WHERE "
                        + " BMMANDANT=:BMMANDANT AND BMBAUMKRS=:BMBAUMKRS AND BMBAUMLFD=:BMBAUMLFD";
                    or1.Parameters.Add("BMMANDANT", OracleType.NVarChar).Value = dwData["BMMANDANT"].ToString();
                    or1.Parameters.Add("BMBAUMKRS", OracleType.NVarChar).Value = dwData["BMBAUMKRS"].ToString();
                    or1.Parameters.Add("BMBAUMLFD", OracleType.NVarChar).Value = dwData["BMBAUMLFD"].ToString();                    
               break;
                case 2:
               or1.CommandText = "SELECT * FROM  BABST"
                   + " WHERE "
                   + " BMMANDANT=:BMMANDANT AND BMAUFKRS=:BMAUFKRS AND BMAUFLFD=:BMAUFLFD AND BMAUFPOS=:BMAUFPOS";
               or1.Parameters.Add("BMMANDANT", OracleType.NVarChar).Value = dwData["BMMANDANT"].ToString();
               or1.Parameters.Add("BMAUFKRS", OracleType.NVarChar).Value = dwData["BMAUFKRS"].ToString();
               or1.Parameters.Add("BMAUFLFD", OracleType.NVarChar).Value = dwData["BMAUFLFD"].ToString();
               or1.Parameters.Add("BMAUFPOS", OracleType.NVarChar).Value = dwData["BMAUFPOS"].ToString();
               break;
                default:
                    break;
            } 

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BABST";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBSSATZ(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM  BSSATZ"
                        + " WHERE "
                        + " BSMANDANT=:BSMANDANT AND BSKART=:BSKART";
                    or1.Parameters.Add("BSMANDANT", OracleType.NVarChar).Value = dwData["BSMANDANT"].ToString();
                    or1.Parameters.Add("BSKART", OracleType.NVarChar).Value = dwData["BSKART"].ToString();

                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT  WF.* FROM WDECK WD "
                        + " JOIN WASTKE ON WDMANDANT=WAKMANDANT AND WDART=WAKART AND WDVAR=WAKVAR AND WDFARBE=WAKWCOL"
                        + " JOIN BSSATZ WF ON BSMANDANT=WAKMANDANT AND BSKART=WAKKART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BSSATZ";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBHSATZ(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM BHSATZ"
                   + " WHERE BHMANDANT=:BHMANDANT AND BHKART=:BHKART AND BHKVAR=:BHKVAR";
                    or1.Parameters.Add("BHMANDANT", OracleType.NVarChar).Value = dwData["BHMANDANT"].ToString();
                    or1.Parameters.Add("BHKART", OracleType.NVarChar).Value = dwData["BHKART"].ToString();
                    or1.Parameters.Add("BHKVAR", OracleType.NVarChar).Value = dwData["BHKVAR"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT  WF.* FROM WDECK WD "
                        + " JOIN WASTKE ON WDMANDANT=WAKMANDANT AND WDART=WAKART AND WDVAR=WAKVAR AND WDFARBE=WAKWCOL"
                        + " JOIN BHSATZ WF ON BHMANDANT=WAKMANDANT AND BHKART=WAKKART AND BHKVAR=WAKKVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BHSATZ";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBSGROE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM  BSGROE"
                        + " WHERE "
                        + " BSGMANDANT=:BSGMANDANT AND BSGART=:BSGART AND BSGMTYP=:BSGMTYP";
                    or1.Parameters.Add("BSGMANDANT", OracleType.NVarChar).Value = dwData["BSGMANDANT"].ToString();
                    or1.Parameters.Add("BSGART", OracleType.NVarChar).Value = dwData["BSGART"].ToString();
                    or1.Parameters.Add("BSGMTYP", OracleType.NVarChar).Value = dwData["BSGMTYP"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT  WF.* FROM WDECK WD "
                        + " JOIN WASTKE ON WDMANDANT=WAKMANDANT AND WDART=WAKART AND WDVAR=WAKVAR AND WDFARBE=WAKWCOL"
                        + " JOIN BSGROE WF ON BSGMANDANT=WAKMANDANT AND BSGART=WAKKART "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BSGROE";

            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBSFARB(DataRow dwData)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            #region===========SELECT==========================
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM BSFARB"
           + " WHERE BSFMANDANT=:BSFMANDANT AND BSFKART=:BSFKART AND BSFKVAR=:BSFKVAR AND BSFKFARBE=:BSFKFARBE";
            or1.Parameters.Add("BSFMANDANT", OracleType.NVarChar).Value = dwData["BSFMANDANT"].ToString();
            or1.Parameters.Add("BSFKART", OracleType.NVarChar).Value = dwData["BSFKART"].ToString();
            or1.Parameters.Add("BSFKVAR", OracleType.NVarChar).Value = dwData["BSFKVAR"].ToString();
            or1.Parameters.Add("BSFKFARBE", OracleType.NVarChar).Value = dwData["BSFKFARBE"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BSFARB";
            }
            #endregion
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBASTGA(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM BASTGA WHERE  "
                    + "  BAGMANDANT=:BAGMANDANT AND BAGART=:BAGART AND BAGVAR=:BAGVAR AND BAGFARBE=:BAGFARBE AND BAGPOS=:BAGPOS";
                    or1.Parameters.Add("BAGMANDANT", OracleType.NVarChar).Value = dwData["BAGMANDANT"].ToString();
                    or1.Parameters.Add("BAGART", OracleType.NVarChar).Value = dwData["BAGART"].ToString();
                    or1.Parameters.Add("BAGVAR", OracleType.NVarChar).Value = dwData["BAGVAR"].ToString();
                    or1.Parameters.Add("BAGFARBE", OracleType.NVarChar).Value = dwData["BAGFARBE"].ToString(); ;
                    or1.Parameters.Add("BAGPOS", OracleType.NVarChar).Value = dwData["BAGPOS"].ToString(); ;
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT WF.* FROM WDECK WD "
                        + " JOIN WASTKE ON WDMANDANT=WAKMANDANT AND WDART=WAKART AND WDVAR=WAKVAR AND WDFARBE=WAKWCOL"
                        + " JOIN BASTGA WF ON BAGMANDANT=WAKMANDANT AND BAGART=WAKKART AND BAGVAR=WAKKVAR AND BAGFARBE=WAKKFARBE"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT WF.* FROM WDECK WD RIGHT JOIN BASTGA WF ON"
                        + "  BAGMANDANT=WDMANDANT  AND BAGART=WDART AND BAGVAR='1 '"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BASTGA";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryBASTGAD(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM BASTGAD WHERE  "
                    + "  BAGMANDANT=:BAGMANDANT AND BAGART=:BAGART AND BAGVAR=:BAGVAR AND BAGFARBE=:BAGFARBE AND BAGPOS=:BAGPOS";
                    or1.Parameters.Add("BAGMANDANT", OracleType.NVarChar).Value = dwData["BAGMANDANT"].ToString();
                    or1.Parameters.Add("BAGART", OracleType.NVarChar).Value = dwData["BAGART"].ToString();
                    or1.Parameters.Add("BAGVAR", OracleType.NVarChar).Value = dwData["BAGVAR"].ToString();
                    or1.Parameters.Add("BAGFARBE", OracleType.NVarChar).Value = dwData["BAGFARBE"].ToString(); ;
                    or1.Parameters.Add("BAGPOS", OracleType.NVarChar).Value = dwData["BAGPOS"].ToString(); ;
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT WF.* FROM WDECK WD RIGHT JOIN BASTGAD WF ON"
                        + "  BAGMANDANT=WDMANDANT  AND BAGART=WDART AND BAGVAR='1 '"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "BASTGAD";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======C==============
        #endregion
        #region======D==============
        public DataSet QueryDSTPLAN(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT SELECT NAME,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE,ABPAUFKRS||'-'||ABPAUFLFD||'-'||ABPAUFPOS,"
                        + " TRIM(B.ABPART)||'.'||TRIM(B.ABPVAR)||'.'||TRIM(B.ABPFARBE) AS DYARN,"
                        + " B.ABPERLKZ,B.ABPERLDAT "
                        + "  FROM DSTPLAN P LEFT JOIN ABKOPF K "
                        + " ON TRIM(P.ORDERNO)=TRIM(K.ABKKDAUFTNR) "
                        + " LEFT JOIN ABPOS B ON K.ABKAUFKRS=B.ABPAUFKRS AND K.ABKAUFLFD=B.ABPAUFLFD "
                        + " WHERE K.ABKAUFART='GP' ";
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT NAME,ARTICLE,'J' AS JW,TRIM(Y.BAGGART)||'.'||TRIM(Y.BAGGVAR)||'.'||TRIM(Y.BAGGFARBE) AS CYARN"
                        + " FROM DSTPLAN P LEFT JOIN BASTGA Y ON"
                        + " TRIM(P.ARTICLE)=TRIM(Y.BAGART)||'-'||TRIM(Y.BAGFARBE)"
                        + " UNION"
                        + " SELECT NAME,ARTICLE,'W' AS JW,TRIM(Y.WAGGART)||'.'||TRIM(Y.WAGGVAR)||'.'||TRIM(Y.WAGGFARBE) AS CYARN"
                        + " FROM DSTPLAN P LEFT JOIN WASTGA Y ON"
                        + " TRIM(P.ARTICLE)=TRIM(Y.WAGART)||'-'||TRIM(Y.WAGWCOL)";
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = " SELECT A.*,ABPAUFKRS||'-'||ABPAUFLFD||'-'||ABPAUFPOS AS ABPORDER,B.ABPLIEFDAT,B.ABPERLKZ,B.ABPERLDAT FROM "
                        + " (SELECT NAME,P.ORDERNO,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE,'J' AS JW,TRIM(Y.BAGGART)||'.'||TRIM(Y.BAGGVAR)||'.'||TRIM(Y.BAGGFARBE) AS CYARN "
                        + " FROM DSTPLAN P LEFT JOIN BASTGA Y ON "
                        + " TRIM(P.ARTICLE)=TRIM(Y.BAGART)||'-'||TRIM(Y.BAGFARBE) "
                        + " UNION "
                        + " SELECT NAME,P.ORDERNO,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE,'W' AS JW,TRIM(Y.WAGGART)||'.'||TRIM(Y.WAGGVAR)||'.'||TRIM(Y.WAGGFARBE) AS CYARN "
                        + " FROM DSTPLAN P LEFT JOIN WASTGA Y ON TRIM(P.ARTICLE)=TRIM(Y.WAGART)||'-'||TRIM(Y.WAGWCOL) "
                        + " ) A LEFT JOIN ABKOPF K "
                        + " ON TRIM(A.ORDERNO)=TRIM(K.ABKKDAUFTNR) "
                        + " LEFT JOIN ABPOS B ON K.ABKAUFKRS=B.ABPAUFKRS AND K.ABKAUFLFD=B.ABPAUFLFD "
                        + " AND A.CYARN=TRIM(B.ABPART)||'.'||TRIM(B.ABPVAR)||'.'||TRIM(B.ABPFARBE)"
                        + " ORDER BY ARTICLE,JW,CYARN";

                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT NAME,P.ORDERNO,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE,"
                    + " ABPAUFKRS||'-'||ABPAUFLFD||'-'||ABPAUFPOS AS ABPORDER, ABPLIEFDAT,ABPERLDAT,ABPSOLLMENGE1*0.01 AS PLANQTY"
                    + ",ABPEALFM*0.01 AS RQTY  "
                    + " FROM DSTPLAN P LEFT JOIN ABPOS B ON TRIM(P.ARTICLE)=TRIM(B.ABPART)||'-'||TRIM(B.ABPFARBE)"
                        + " WHERE B.ABPAUFART='VW'";
                    break;
                case 5:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT NAME,P.ORDERNO,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE, "
                        + " ABPAUFKRS||'-'||ABPAUFLFD||'-'||ABPAUFPOS AS ABPORDER, ABPLIEFDAT,ABPSOLLMENGE2*0.01 AS PLANQTY,ABPZUGET*0.01 AS MQTY,"
                        + " ABPEBLFM*0.01 AS RQTY ,ABPERLDAT FROM DSTPLAN P  "
                        + " LEFT JOIN ABPOS B ON TRIM(P.ARTICLE)=TRIM(B.ABPART)||'-'||TRIM(B.ABPFARBE) WHERE B.ABPAUFART='PR'";
                    break;
                case 6:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT NAME,P.ORDERNO,ARTICLE,YARN,FDDIS,QTY,UNIT,REQDATE, "
                        + "ABPAUFKRS||'-'||ABPAUFLFD||'-'||ABPAUFPOS AS ABPORDER, ABPERLDAT,ABPSOLLMENGE1*0.01 AS PLANQTY,"
                        + "ABPSOLLMENGE2*0.01 AS PMQTY，ABPZUGET*0.01 AS MQTY"
                        + ",ABPEBLFM*0.01 AS RQTY  FROM DSTPLAN P  "
                        + "LEFT JOIN ABPOS B ON TRIM(P.ARTICLE)=TRIM(B.ABPART)||'-'||TRIM(B.ABPFARBE) WHERE B.ABPAUFART='VA'";
                    break;
                default:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM ABPOS WHERE  "
                    + "  ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "DSTPLAN";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======E==============
        public DataSet QueryEKKOPF(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM EKKOPF  "
                        + " WHERE EKKMANDANT=:EKKMANDANT  AND EKKAUFKRS=:EKKAUFKRS  AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM EKKOPF WHERE EKKMANDANT=:EKKMANDANT  AND EKKLIEFNR=:EKKLIEFNR";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKLIEFNR", OracleType.NVarChar).Value = dwData["EKKLIEFNR"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM EKKOPF  "
                        + " WHERE EKKMANDANT=:EKKMANDANT  AND EKKAUFKRS=:EKKAUFKRS  AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "EKKOPF";
            Return = Result;
            return Return;
        }
        public DataSet QueryEKVRECH(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {

                case 1:
                    or1.CommandText = "SELECT * FROM EKVRECH WHERE EKVMANDANT=:EKVMANDANT  AND EKVABLAGE=:EKVABLAGE AND EKVBELEG=:EKVBELEG";
                    or1.Parameters.Add("EKVMANDANT", OracleType.NVarChar).Value = dwData["EKVMANDANT"].ToString();
                    or1.Parameters.Add("EKVABLAGE", OracleType.NVarChar).Value = dwData["EKVABLAGE"].ToString();
                    or1.Parameters.Add("EKVBELEG", OracleType.NVarChar).Value = dwData["EKVBELEG"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM EKVRECH  "
                        + " WHERE EKVMANDANT=:EKVMANDANT  AND EKVRECHNR LIKE '" + dwData["EKVRECHNR"].ToString().Trim() + "%'";
                    or1.Parameters.Add("EKVMANDANT", OracleType.NVarChar).Value = dwData["EKVMANDANT"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "EKVRECH";
            Return = Result;
            return Return;
        }
        public DataSet QueryEKPOS(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM EKPOS WHERE  "
                    + "  EKPSA<>'AJ'  AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD AND EKPAUFPOS=:EKPAUFPOS  ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    or1.Parameters.Add("EKPAUFPOS", OracleType.NVarChar).Value = dwData["EKPAUFPOS"].ToString(); ;
                    break;
                case 2:
                    or1.CommandText = "SELECT EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPWE1,EKPLTERM,EKPME1,EKPMEEH,EKPPRME"
                         + ",  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                         + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR"
                         + ", utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE "
                        + "  FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 901:
                    FSARTPRGR = dwData["ABPART"].ToString().Trim();
                    or1.CommandText = " SELECT LSLIEFNA,FSKOLL,FSARTPRGR,SUM(EKPME1*0.01) AS EKPME1,EKPMEEH,SUM(EKPWE1*0.01) AS EKPWE1 FROM EKPOS JOIN"
                        + " (SELECT DISTINCT ABAMANDANT,ABPART,FSARTPRGR,FSKOLL,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS FROM ICC_ABAUFM"
                        + " WHERE ABAMANDANT=:ABAMANDANT AND FSKOLL=:FSKOLL  AND FSARTPRGR IN(" + FSARTPRGR+") ) A ON"
                        + "  ABAMANDANT=EKPMANDANT AND ABAAUFKRS=EKPAUFKRS AND ABAAUFLFD=EKPAUFLFD AND ABAAUFPOS=EKPAUFPOS  "
                        + " JOIN LIEFDAT ON LSLIEFNR=EKPLIEFNR"
                        + "   WHERE EKPMANDANT=:ABAMANDANT AND EKPSA='PO' "
                        + "  GROUP BY LSLIEFNA,ABPART,FSKOLL,FSARTPRGR,EKPMEEH"
                        + " ORDER BY FSKOLL,FSARTPRGR,LSLIEFNA ";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("FSKOLL", OracleType.NVarChar).Value = dwData["FSKOLL"].ToString();
                    break;
                case 902:
                    FSARTPRGR = dwData["FSABEZ"].ToString().Trim();
                    or1.CommandText = "SELECT ABPART,ABPFARBE,ABAART,ABAFARBE,ABAGROE,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS"
                    + ",SUM(ABARESMG) AS ABARESMG,SUM(ABAQTYRESERVE) AS ABAQTYRESERVE"
                    + ",MAX(FSABEZ) AS FSABEZ ,MAX(FSFFBEZ) AS FSFFBEZ,LSNAME1,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR"
                    +" FROM ICC_ABAUFM "
                    +" LEFT JOIN EKPOS ON EKPSA='PO' AND EKPAUFKRS=ABAAUFKRS AND EKPAUFLFD=ABAAUFLFD AND EKPAUFPOS=ABAAUFPOS "
                    +" LEFT JOIN LIEFDAT LS ON LS.LSLIEFNR=EKPLIEFNR"
                    +" WHERE ABAMANDANT=:ABAMANDANT AND FSKOLL=:FSKOLL"
                    + "  AND ABPART LIKE '%" + dwData["ABPART"].ToString().Trim() 
                    + "%' AND ABAART LIKE '%" + dwData["ABAART"].ToString().Trim()+"%'"
                    + " GROUP BY  LSNAME1,ABPART,ABPFARBE,ABAART,ABAFARBE,ABAGROE,ABAAUFKRS,ABAAUFLFD,ABAAUFPOS"
                    + " ORDER BY LSNAME1,ABPART,ABPFARBE,ABAART,ABAFARBE,ABAGROE";
                    or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwData["ABAMANDANT"].ToString();
                    or1.Parameters.Add("FSKOLL", OracleType.NVarChar).Value = dwData["FSKOLL"].ToString();
                    break;
                case 99:
                    or1.CommandText = " SELECT DISTINCT EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,ABAVKAUFKRS,ABAVKAUFLFD,ABAVKAUFPOS,MU.ABAART,MU.ABAVAR,MU.ABAFARBE,ABAGROE,EK.EKPPRME*0.001 AS PRICE,EKPPREH AS UM,WAFGRLFD FROM EKPOS EK"
                        + " JOIN ICC_ABAUFM MU ON MU.ABAAUFKRS=EK.EKPAUFKRS AND MU.ABAAUFLFD=EK.EKPAUFLFD AND MU.ABAAUFPOS=EK.EKPAUFPOS"
                        + " WHERE EKPSA<>'AJ' AND MU.ABAVKAUFKRS=:ABAVKAUFKRS AND MU.ABAVKAUFLFD=:ABAVKAUFLFD AND "
                        + " MU.ABAART=:ABAART AND MU.ABAVAR=:ABAVAR AND MU.ABAFARBE=:ABAFARBE AND ABAGROE=:ABAGROE";
                    or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwData["ABAVKAUFKRS"].ToString();
                    or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwData["ABAVKAUFLFD"].ToString();
                    or1.Parameters.Add("ABAART", OracleType.NVarChar).Value = dwData["ABAART"].ToString();
                    or1.Parameters.Add("ABAVAR", OracleType.NVarChar).Value = dwData["ABAVAR"].ToString();
                    or1.Parameters.Add("ABAFARBE", OracleType.NVarChar).Value = dwData["ABAFARBE"].ToString();
                    or1.Parameters.Add("ABAGROE", OracleType.NVarChar).Value = dwData["ABAGROE"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "EKPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryICC_EKPOS(string client, string wakz, string art, string var, string color, string size, string EKPBEKZ, int option)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,EKPPRME,"
                        + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE,EKPLSGRPBEZ FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ "
                        + " AND utl_raw.cast_to_varchar2(EKPART)=:EKPART AND utl_raw.cast_to_varchar2(EKPVAR)=:EKPVAR   AND utl_raw.cast_to_varchar2(EKPFARBE)=:EKPFARBE "
                        + "AND EKPGROE=:EKPGROE";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPART", OracleType.NVarChar).Value = art;
                    or1.Parameters.Add("EKPVAR", OracleType.NVarChar).Value = var;
                    or1.Parameters.Add("EKPFARBE", OracleType.NVarChar).Value = color;
                    or1.Parameters.Add("EKPGROE", OracleType.NVarChar).Value = size;
                    break;
                case 2://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,EKPPRME,"
                        + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE,EKPLSGRPBEZ FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPME1-EKPME3>0 AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ "
                        + " AND utl_raw.cast_to_varchar2(EKPART)=:EKPART AND utl_raw.cast_to_varchar2(EKPVAR)=:EKPVAR   AND utl_raw.cast_to_varchar2(EKPFARBE)=:EKPFARBE "
                        + "AND EKPGROE=:EKPGROE";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPART", OracleType.NVarChar).Value = art;
                    or1.Parameters.Add("EKPVAR", OracleType.NVarChar).Value = var;
                    or1.Parameters.Add("EKPFARBE", OracleType.NVarChar).Value = color;
                    or1.Parameters.Add("EKPGROE", OracleType.NVarChar).Value = size;
                    break;
                case 3://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPBEKZ, EKPLSART,EKPLSFB,"
                    + "utl_raw.cast_to_varchar2(EKPART) AS EKPART,WAFBRTU,WAFBRTL,EKPEART,EKPEFARBE"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,"
                        + "  EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPPRME,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE FROM EKPOS P  "
                        + " LEFT JOIN WASTAMM ON WAART=utl_raw.cast_to_varchar2(EKPART)  "
                         + " WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ AND EKPME3=0  "
                        + " AND utl_raw.cast_to_varchar2(EKPART) LIKE '" + art.Trim() + "%'  "
                        + " AND EKPBEKZ=:EKPBEKZ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = EKPBEKZ;
                    break;
                case 4://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,EKPPRME,"
                        + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE,EKPLSGRPBEZ FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPME1-EKPME3>0 AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ "
                        //+ " EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ "
                        + " AND utl_raw.cast_to_varchar2(EKPART)=:EKPART AND utl_raw.cast_to_varchar2(EKPVAR)=:EKPVAR   AND utl_raw.cast_to_varchar2(EKPFARBE)=:EKPFARBE "
                        + "AND EKPGROE=:EKPGROE";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPART", OracleType.NVarChar).Value = art;
                    or1.Parameters.Add("EKPVAR", OracleType.NVarChar).Value = var;
                    or1.Parameters.Add("EKPFARBE", OracleType.NVarChar).Value = color;
                    or1.Parameters.Add("EKPGROE", OracleType.NVarChar).Value = size;
                    break;
                case 5://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPBEKZ, EKPLSART,EKPLSFB,"
                    + "utl_raw.cast_to_varchar2(EKPART) AS EKPART,WAFBRTU,WAFBRTL,EKPEART,EKPEFARBE"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,"
                        + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPPRME,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE FROM EKPOS P "
                         + " LEFT JOIN WASTAMM ON WAART=utl_raw.cast_to_varchar2(EKPART)  "
                         + " WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ"
                        + " AND utl_raw.cast_to_varchar2(EKPART) LIKE '" + art.Trim() + "%'  "
                        + " AND EKPBEKZ=:EKPBEKZ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = EKPBEKZ;
                    break;

                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_EKPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryICC_EKPOS(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1://material
                    or1.CommandText = "SELECT EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPWE1,EKPLTERM,EKPME1,EKPMEEH,EKPPRME,EKPLSGRPBEZ"
                        + ",EKPZUAB1,EKPZUABPR1,EKPZUABWE1,EKPZUABME1,EKPABRKZ1,EKPZUAB2,EKPZUABPR2,EKPZUABWE2,EKPZUABME2,EKPABRKZ2,EKPZUAB3,EKPZUABPR3,"
                        + "EKPZUABWE3,EKPZUABME3	,EKPABRKZ3,EKPZUAB4,EKPZUABPR4,EKPZUABWE4,EKPZUABME4,EKPABRKZ4,EKPZUAB5,EKPZUABPR5,EKPZUABWE5,"
                        + "EKPZUABME5	,EKPABRKZ5,	EKPZUABWERT"
                         + ",  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                         + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR"
                         + ", utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE "
                        + "  FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;

                case 2://material
                    or1.CommandText = "SELECT * "
                        + "  FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 3://material
                    string EKPBEKZ = dwData["EKPBEKZ"].ToString();
                    string EKPKNTRNRL = dwData["EKPKNTRNRL"].ToString();
                    or1.CommandText = "SELECT EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPBEKZ,EKPLIEFNR,EKPWE1,EKPLTERM,EKPME1,EKPMEEH,EKPPRME,EKPLSGRPBEZ"
                        + ",EKPZUAB1,EKPZUABPR1,EKPZUABWE1,EKPZUABME1,EKPABRKZ1,EKPZUAB2,EKPZUABPR2,EKPZUABWE2,EKPZUABME2,EKPABRKZ2,EKPZUAB3,EKPZUABPR3,"
                        + "EKPZUABWE3,EKPZUABME3	,EKPABRKZ3,EKPZUAB4,EKPZUABPR4,EKPZUABWE4,EKPZUABME4,EKPABRKZ4,EKPZUAB5,EKPZUABPR5,EKPZUABWE5,"
                        + "EKPZUABME5	,EKPABRKZ5,	EKPZUABWERT,EKPKNTRNRL"
                         + ",  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                         + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR"
                         + ", utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE "
                        + "  FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD AND EKPBEKZ IN ( " + EKPBEKZ + ") AND trim(EKPKNTRNRL) IS " + EKPKNTRNRL + " NULL";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 4://material                  
                    or1.CommandText = "SELECT EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPWE1,EKPLTERM,EKPME1,EKPMEEH,EKPPRME,EKPLSGRPBEZ"
                        + ",EKPZUAB1,EKPZUABPR1,EKPZUABWE1,EKPZUABME1,EKPABRKZ1,EKPZUAB2,EKPZUABPR2,EKPZUABWE2,EKPZUABME2,EKPABRKZ2,EKPZUAB3,EKPZUABPR3,"
                        + "EKPZUABWE3,EKPZUABME3	,EKPABRKZ3,EKPZUAB4,EKPZUABPR4,EKPZUABWE4,EKPZUABME4,EKPABRKZ4,EKPZUAB5,EKPZUABPR5,EKPZUABWE5,"
                        + "EKPZUABME5	,EKPABRKZ5,	EKPZUABWERT,EKPKNTRNRL,EKPBEKZ"
                         + ",  utl_raw.cast_to_varchar2(EKPART) AS EKPART"
                         + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR"
                         + ", utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE "
                        + "  FROM EKPOS P WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 31://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPBEKZ, EKPLSART,EKPLSFB,"
                    + "utl_raw.cast_to_varchar2(EKPART) AS EKPART,WAFBRTU,WAFBRTL,EKPEART,EKPEFARBE"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,"
                        + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPPRME,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE FROM EKPOS P"
                        + " LEFT JOIN WASTAMM ON WAART=utl_raw.cast_to_varchar2(EKPART) "
                        + " WHERE  "
                         + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPME3=0 "
                        + " AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD "
                        + " AND EKPBEKZ=:EKPBEKZ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["EKPBEKZ"].ToString();
                    break;
                case 51://material
                    or1.CommandText = "SELECT 1 AS EKPAID,EKPMANDANT,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPNEUD,EKPNEUB,EKPARTGR,EKPWAKZ,EKPBEKZ, EKPLSART,EKPLSFB,"
                    + "utl_raw.cast_to_varchar2(EKPART) AS EKPART,WAFBRTU,WAFBRTL,EKPEART,EKPEFARBE"
                    + ",  utl_raw.cast_to_varchar2(EKPVAR) AS EKPVAR, utl_raw.cast_to_varchar2(EKPFARBE) AS EKPFARBE,EKPDESS,EKPCOL,EKPGROE,"
                    + "    EKPMEEH,EKPME1*0.01 AS EKPME1 ,EKPPRME,EKPLTERM,0 AS EKPQTYLOCKED,EKPME1*0.01 AS EKPQTYFREE FROM EKPOS P "
                    + " LEFT JOIN WASTAMM ON WAART=utl_raw.cast_to_varchar2(EKPART)  "
                    + " WHERE  "
                    + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT  "
                    + " AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD "
                    + " AND EKPBEKZ=:EKPBEKZ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["EKPBEKZ"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_EKPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryEKPOS(string client, string krs, string lfd, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM EKPOS WHERE EKPSA<>'AJ' AND  EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = lfd;
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "EKPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryEKPOS(string client, string wakz, string art, string var, string color, int option)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 2://material
                    or1.CommandText = "SELECT * FROM EKPOS WHERE  "
                        + "  EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPWAKZ=:EKPWAKZ "
                        + " AND utl_raw.cast_to_varchar2(EKPART)=:EKPART AND utl_raw.cast_to_varchar2(EKPVAR)=:EKPVAR  ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("EKPWAKZ", OracleType.NVarChar).Value = wakz;
                    or1.Parameters.Add("EKPART", OracleType.NVarChar).Value = art;
                    or1.Parameters.Add("EKPVAR", OracleType.NVarChar).Value = var;
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "EKPOS";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======F==============
        /*  
 
SELECT * FROM 
GO
SELECT * FROM INTEX.FSZSTECH f
GO*/
        public DataSet QueryICC_FBST(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM FBST  "
                            + " WHERE FBMANDANT=:FBMANDANT AND FBART=:FBART AND FBVAR=:FBVAR AND FBFARBE=:FBFARBE AND FBGROE=:FBGROE";
                    or1.Parameters.Add("FBMANDANT", OracleType.NVarChar).Value = dwData["FBMANDANT"].ToString();
                    or1.Parameters.Add("FBART", OracleType.NVarChar).Value = dwData["FBART"].ToString();
                    or1.Parameters.Add("FBVAR", OracleType.NVarChar).Value = dwData["FBVAR"].ToString();
                    or1.Parameters.Add("FBFARBE", OracleType.NVarChar).Value = dwData["FBFARBE"].ToString();
                    or1.Parameters.Add("FBGROE", OracleType.NVarChar).Value = dwData["FBGROE"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_FBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryFBST(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM FBST "
                        + " WHERE FBMANDANT=:FBMANDANT AND FBART=:FBART AND FBVAR=:FBVAR AND FBFARBE=:FBFARBE AND FBGROE=:FBGROE AND FBLO=:FBLO AND FBLB=:FBLB AND FBLP=:FBLP";
                    or1.Parameters.Add("FBMANDANT", OracleType.NVarChar).Value = dwData["FBMANDANT"].ToString();
                    or1.Parameters.Add("FBART", OracleType.NVarChar).Value = dwData["FBART"].ToString();
                    or1.Parameters.Add("FBVAR", OracleType.NVarChar).Value = dwData["FBVAR"].ToString();
                    or1.Parameters.Add("FBFARBE", OracleType.NVarChar).Value = dwData["FBFARBE"].ToString();
                    or1.Parameters.Add("FBGROE", OracleType.NVarChar).Value = dwData["FBGROE"].ToString();
                    or1.Parameters.Add("FBLO", OracleType.NVarChar).Value = dwData["FBLO"].ToString();
                    or1.Parameters.Add("FBLB", OracleType.NVarChar).Value = dwData["FBLB"].ToString();
                    or1.Parameters.Add("FBLP", OracleType.NVarChar).Value = dwData["FBLP"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT  1 AS BAID,FBMANDANT AS MANDANT "
                        + "  ,FBART AS ART,FBVAR AS VAR,FBFARBE AS COLOR, FBGROE AS ASIZE,"
                        + "  FBLO AS LO,FBLB AS LB,FBLP AS LP,FBVPEINH AS LOT,FBME AS QTY,0 AS QTYLOCKED,FBME AS QTYFREE"
                        + " FROM FBST "
                        + " WHERE FBMANDANT=:FBMANDANT AND FBART=:FBART AND FBVAR=:FBVAR AND FBFARBE=:FBFARBE AND FBGROE=:FBGROE";
                    or1.Parameters.Add("FBMANDANT", OracleType.NVarChar).Value = dwData["FBMANDANT"].ToString();
                    or1.Parameters.Add("FBART", OracleType.NVarChar).Value = dwData["FBART"].ToString();
                    or1.Parameters.Add("FBVAR", OracleType.NVarChar).Value = dwData["FBVAR"].ToString();
                    or1.Parameters.Add("FBFARBE", OracleType.NVarChar).Value = dwData["FBFARBE"].ToString();
                    or1.Parameters.Add("FBGROE", OracleType.NVarChar).Value = dwData["FBGROE"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM FBST "
                        + " WHERE FBMANDANT=:FBMANDANT AND FBCHAR=:FBCHAR AND FBLO=:FBLO AND FBLB=:FBLB AND FBLP=:FBLP";
                    or1.Parameters.Add("FBMANDANT", OracleType.NVarChar).Value = dwData["FBMANDANT"].ToString();
                    or1.Parameters.Add("FBCHAR", OracleType.NVarChar).Value = dwData["FBCHAR"].ToString();
                    or1.Parameters.Add("FBLO", OracleType.NVarChar).Value = dwData["FBLO"].ToString();
                    or1.Parameters.Add("FBLB", OracleType.NVarChar).Value = dwData["FBLB"].ToString();
                    or1.Parameters.Add("FBLP", OracleType.NVarChar).Value = dwData["FBLP"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM FBST "
                        + " WHERE FBMANDANT=:FBMANDANT AND FBART=:FBART AND FBVAR=:FBVAR AND FBFARBE=:FBFARBE AND FBGROE=:FBGROE AND FBLO=:FBLO AND FBLB=:FBLB"
                        + " ORDER BY FBCHAR";
                    or1.Parameters.Add("FBMANDANT", OracleType.NVarChar).Value = dwData["FBMANDANT"].ToString();
                    or1.Parameters.Add("FBART", OracleType.NVarChar).Value = dwData["FBART"].ToString();
                    or1.Parameters.Add("FBVAR", OracleType.NVarChar).Value = dwData["FBVAR"].ToString();
                    or1.Parameters.Add("FBFARBE", OracleType.NVarChar).Value = dwData["FBFARBE"].ToString();
                    or1.Parameters.Add("FBGROE", OracleType.NVarChar).Value = dwData["FBGROE"].ToString();
                    or1.Parameters.Add("FBLO", OracleType.NVarChar).Value = dwData["FBLO"].ToString();
                    or1.Parameters.Add("FBLB", OracleType.NVarChar).Value = dwData["FBLB"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "FBST";
            Return = Result;
            return Return;
        }

        public DataSet QueryFCHAR(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM FCHAR "
                        + " WHERE FCMANDANT=:FCMANDANT AND FCAUFTYP=:FCAUFTYP AND FCBESTKRS=:FCBESTKRS AND FCBESTLFD=:FCBESTLFD AND FCBESTPOS=:FCBESTPOS";
                    or1.Parameters.Add("FCMANDANT", OracleType.NVarChar).Value = dwData["FCMANDANT"].ToString();
                    or1.Parameters.Add("FCAUFTYP", OracleType.NVarChar).Value = dwData["FCAUFTYP"].ToString();
                    or1.Parameters.Add("FCBESTKRS", OracleType.NVarChar).Value = dwData["FCBESTKRS"].ToString();
                    or1.Parameters.Add("FCBESTLFD", OracleType.NVarChar).Value = dwData["FCBESTLFD"].ToString();
                    or1.Parameters.Add("FCBESTPOS", OracleType.NVarChar).Value = dwData["FCBESTPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM FCHAR "
           + " WHERE FCMANDANT=:FCMANDANT AND FCCHAR=:FCCHAR";
                    or1.Parameters.Add("FCMANDANT", OracleType.NVarChar).Value = dwData["FCMANDANT"].ToString();
                    or1.Parameters.Add("FCCHAR", OracleType.NVarChar).Value = dwData["FCCHAR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "FCHAR";
            Return = Result;
            return Return;
        }
        public DataSet QueryFGBST(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM FGBST "
                        + " WHERE FGMANDANT=:FGMANDANT AND FGMJJ=:FGMJJ AND FGMM=:FGMM AND FGART=:FGART AND FGVAR=:FGVAR AND FGFARBE=:FGFARBE AND FGGROE=:FGGROE"
                        + " AND FGLO=:FGLO";
                    or1.Parameters.Add("FGMANDANT", OracleType.NVarChar).Value = dwData["FGMANDANT"].ToString();
                    or1.Parameters.Add("FGART", OracleType.NVarChar).Value = dwData["FGART"].ToString();
                    or1.Parameters.Add("FGVAR", OracleType.NVarChar).Value = dwData["FGVAR"].ToString();
                    or1.Parameters.Add("FGFARBE", OracleType.NVarChar).Value = dwData["FGFARBE"].ToString();
                    or1.Parameters.Add("FGGROE", OracleType.NVarChar).Value = dwData["FGGROE"].ToString();
                    or1.Parameters.Add("FGLO", OracleType.NVarChar).Value = dwData["FGLO"].ToString();
                    or1.Parameters.Add("FGMJJ", OracleType.NVarChar).Value = dwData["FGMJJ"].ToString();
                    or1.Parameters.Add("FGMM", OracleType.NVarChar).Value = dwData["FGMM"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "FGBST";
            Return = Result;
            return Return;
        }

        public DataSet QueryFBEW(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1://FBWJJJJ	FBWBELEG	FBWLFDNR

                    or1.CommandText = "SELECT * FROM FBEW"
                        + " WHERE FBWMANDANT=:FBWMANDANT AND FBWJJJJ=:FBWJJJJ AND FBWBELEG=:FBWBELEG AND FBWLFDNR=:FBWLFDNR  ";
                    or1.Parameters.Add("FBWMANDANT", OracleType.NVarChar).Value = dwData["FBWMANDANT"].ToString();
                    or1.Parameters.Add("FBWJJJJ", OracleType.NVarChar).Value = dwData["FBWJJJJ"].ToString();
                    or1.Parameters.Add("FBWBELEG", OracleType.NVarChar).Value = dwData["FBWBELEG"].ToString();
                    or1.Parameters.Add("FBWLFDNR", OracleType.NVarChar).Value = dwData["FBWLFDNR"].ToString();

                    break;
                case 99:
                    or1.CommandText = "SELECT FBWAUFKRS,FBWAUFLFD,FBWAUFPOS,FBWART,FBWVAR,FBWFARBE,FBWGROE,FBWBS,SUM(FBWME) AS FBWME"
                    + " FROM FBEW"
                    + " WHERE FBWMANDANT=:FBWMANDANT AND FBWAUFTYP='V' AND FBWAUFKRS=:FBWAUFKRS AND FBWAUFLFD=:FBWAUFLFD  "
                    + " GROUP BY FBWAUFTYP,FBWAUFKRS,FBWAUFLFD,FBWAUFPOS,FBWART,FBWVAR,FBWFARBE,FBWGROE,FBWBS";
                    or1.Parameters.Add("FBWMANDANT", OracleType.NVarChar).Value = dwData["FBWMANDANT"].ToString();
                    or1.Parameters.Add("FBWAUFKRS", OracleType.NVarChar).Value = dwData["FBWAUFKRS"].ToString();
                    or1.Parameters.Add("FBWAUFLFD", OracleType.NVarChar).Value = dwData["FBWAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "FBEW";
            Return = Result;
            return Return;
        }
        public DataSet QueryFDECK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM FDECK  "
                        + " WHERE FDMANDANT=:FDMANDANT AND FDSA=:FDSA AND FDTYP=:FDTYP AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD AND FDAUFPOS=:FDAUFPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDSA", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDAUFPOS", OracleType.NVarChar).Value = dwData["FDAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM FDECK  "
                        + " WHERE FDMANDANT=:FDMANDANT AND FDSA=:FDSA AND FDTYP=:FDTYP AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD AND FDAUFPOS=:FDAUFPOS"
                        + " AND FDAFOLGE=:FDAFOLGE  AND FDSETPOS=:FDSETPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDSA", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDAUFPOS", OracleType.NVarChar).Value = dwData["FDAUFPOS"].ToString();
                    or1.Parameters.Add("FDAFOLGE", OracleType.NVarChar).Value = dwData["FDAFOLGE"].ToString();
                    or1.Parameters.Add("FDSETPOS", OracleType.NVarChar).Value = dwData["FDSETPOS"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT DISTINCT ABKMANDANT, ABKAUFKRS,ABKAUFLFD,ABPART,FSABEZ  ,LSLIEFNA AS EXTPRODUCER,ABPLIEFNR,ABPANRKR,ABPALFDNR "
                    + " FROM FDECK F JOIN ABKOPF K ON F.FDAUFKRS=K.ABKAUFKRS AND  F.FDAUFLFD=K.ABKAUFLFD"
                    + " JOIN ABPOS P ON F.FDAUFKRS=P.ABPAUFKRS AND  F.FDAUFLFD=P.ABPAUFLFD AND  F.FDAUFPOS=P.ABPAUFPOS AND ABPGESSTA='SP'"
                    + " LEFT JOIN FSSTAMM M ON ABPART=FSART"
                    + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                    + " WHERE F.FDART=:FDART AND F.FDTYP=:FDTYP";
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM FDECK  "
                        + " WHERE FDMANDANT=:FDMANDANT AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,FD.* FROM FDECK FD"
                    + "   JOIN ABPOS P ON FDAUFKRS=ABPAUFKRS AND FDAUFLFD=ABPAUFLFD AND FDAUFPOS=ABPAUFPOS  "
                        + " WHERE FDMANDANT=:FDMANDANT AND FDART=:FDART";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT FD.* FROM FDECK FD"
                        + " WHERE FDMANDANT=:FDMANDANT AND FDAUFKRS=:FDAUFKRS AND FDAUFLFD=:FDAUFLFD AND FDAUFPOS=:FDAUFPOS"
                        + " AND FDART=:FDART AND FDVAR=:FDVAR AND FDFARBE=:FDFARBE AND FDGROE=:FDGROE";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDAUFPOS", OracleType.NVarChar).Value = dwData["FDAUFPOS"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    or1.Parameters.Add("FDVAR", OracleType.NVarChar).Value = dwData["FDVAR"].ToString();
                    or1.Parameters.Add("FDFARBE", OracleType.NVarChar).Value = dwData["FDFARBE"].ToString();
                    or1.Parameters.Add("FDGROE", OracleType.NVarChar).Value = dwData["FDGROE"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT FD.* FROM FDECK FD"
                        + " WHERE FDMANDANT=:FDMANDANT AND FDAUFKRS=:FDAUFKRS AND FDAUFLFD=:FDAUFLFD"
                        + " AND FDART=:FDART ";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    break;
                case 8:
                    string FDART =Left( dwData["FDFILLER"].ToString(),20);
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,FD.* FROM FDECK FD"
                    + "   JOIN ABPOS P ON FDAUFKRS=ABPAUFKRS AND FDAUFLFD=ABPAUFLFD AND FDAUFPOS=ABPAUFPOS  "
                        + " WHERE FDMANDANT=:FDMANDANT AND ABPART=:ABPART AND FDART=:FDART";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["FDART"].ToString();
                    or1.Parameters.Add("FDART", OracleType.NVarChar).Value = FDART;
                    break;
                case 9://分组 
                    FSARTPRGR = dwData["FDART"].ToString().Trim();
                    or1.CommandText = "SELECT DISTINCT A.*,Trim(C.FSFFBEZ) AS CDES,SP.LSLIEFNA AS SELLER, SP.LSNAME1 AS SELLERNAME "
                   + " FROM (SELECT DISTINCT FDMANDANT AS MANDANT,FDTYP AS DTYP,FDART AS ART,FDVAR AS VAR,FDFARBE AS COLOR ,"
                   + " Trim(MAX(S.FSABEZ))AS ARTDES, FDGROE AS ASIZE,ABACOLORREF AS CREF,"
                   + " SUM(ABARESMG) AS REQ,NVL(MAX(S.FSUEBM),'PCS') AS UM "
                   + " FROM INTEX.FDECK R "
                   + " JOIN INTEX.ICC_ABAUFM M ON R.FDAUFKRS=M.ABAVKAUFKRS AND R.FDAUFLFD=M.ABAVKAUFLFD AND R.FDAUFPOS=M.ABAVKAUFPOS AND ABAART=FDART AND  "
                   + " ABAVAR =FDVAR AND  ABAFARBE= FDFARBE  AND ABAGROE=FDGROE JOIN ABPOS P ON ABPSPGRD<='89' AND"
                   + " P.ABPAUFKRS=R.FDAUFKRS AND P.ABPAUFLFD=R.FDAUFLFD AND P.ABPAUFPOS=R.FDAUFPOS LEFT JOIN FSSTAMM S"
                   + " ON R.FDART=S.FSART AND R.FDVAR=S.FSVAR  "
                   + " WHERE  FDMANDANT=:FDMANDANT  AND FDTYP=:FDTYP AND FDSA=:FDSA AND FDZUGET=0 AND FDRESERV=0 AND M.ABAAUFTYP='N'"
                        //''+" AND FDART LIKE 'B140100115%' "
                   + " GROUP BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF"
                   + " ORDER BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF"
                   + " ) A   LEFT JOIN FSFARBEN C ON A.ART=FSFART AND A.VAR=FSFVAR AND A.COLOR=C.FSFFARBE"
                   + " LEFT JOIN FSEINK K ON A.ART=K.FEART AND A.VAR=K.FEVAR "
                   + " LEFT JOIN LIEFDAT SP ON FELIEFNR=SP.LSLIEFNR";

                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("FDSA", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    break;
                case 10:
                    or1.CommandText = "SELECT FD.*,0 AS RATIO"
                        + " FROM FDECK FD"
                        + " WHERE FDMANDANT=:FDMANDANT AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    break;
                case 11:
                    or1.CommandText = "SELECT FD.*,0 AS RATIO"
                        + " FROM FDECK FD"
                        + " WHERE FDMANDANT=:FDMANDANT AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD AND FDAUFPOS=:FDAUFPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDAUFPOS", OracleType.NVarChar).Value = dwData["FDAUFPOS"].ToString();
                    break;
                case 12:
                    or1.CommandText = "SELECT * FROM FDECK  "
                        + " WHERE FDMANDANT=:FDMANDANT  AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD AND FDAUFPOS=:FDAUFPOS";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    or1.Parameters.Add("FDAUFPOS", OracleType.NVarChar).Value = dwData["FDAUFPOS"].ToString();
                    break;
                case 16:
                    or1.CommandText = "SELECT DISTINCT FDART AS WDART FROM EKPOS EK JOIN FDECK ON "
                        + " EKPSA<>'AJ'  AND utl_raw.cast_to_varchar2(EKPART)=FDART  "
                        + " AND utl_raw.cast_to_varchar2(EKPFARBE)=FDFARBE  AND EKPGROE=FDGROE AND EKPBEKZ=:EKPBEKZ"
                        + " JOIN ABPOS ON ABPAUFKRS=FDAUFKRS AND ABPAUFLFD=FDAUFLFD AND ABPAUFPOS=FDAUFPOS"
                        + " JOIN FSSTAMM M ON FSART=ABPART"
                        + " JOIN FSSTUELI ON ABPART=FSSART AND FDART=FSSMART AND "
                        + " M.FSARTPRGR IN  (" + dwData["FDART"].ToString().Trim() + ")"
                        + " WHERE FDMANDANT=:FDMANDANT AND FDTYP=:FDTYP";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    break;
                case 17:
                    or1.CommandText = "SELECT DISTINCT FSART AS WDART FROM EKPOS EK JOIN FSSTAMM M ON "
                        + " EKPSA<>'AJ'  AND utl_raw.cast_to_varchar2(EKPART)=FSART AND EKPBEKZ=:EKPBEKZ "
                        + " M.FSARTPRGR IN  (" + dwData["FDART"].ToString().Trim() + ")"
                        + " WHERE FSMANDANT=:FDMANDANT ";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 91://分组 
                    string art = dwData["FDART"].ToString().Trim();
                    or1.CommandText = "SELECT DISTINCT A.*,Trim(C.FSFFBEZ) AS CDES,NVL(SP.LSLIEFNA,'YCA       ') AS SELLER, NVL(SP.LSNAME1,'YCA                                     ') AS SELLERNAME "
                    + " FROM (SELECT DISTINCT FDMANDANT AS MANDANT,FDTYP AS DTYP,FDART AS ART,FDVAR AS VAR,FDFARBE AS COLOR ,"
                    + " Trim(MAX(S.FSABEZ))AS ARTDES, FDGROE AS ASIZE,ABACOLORREF AS CREF,M.ABPART,MAX(M.FSABEZ) AS FSABEZ,"
                    + " SUM(ABARESMG) AS REQ,NVL(MAX(S.FSUEBM),'PCS') AS UM "
                    + " FROM INTEX.FDECK R "
                    + " JOIN INTEX.ICC_ABAUFM M ON R.FDAUFKRS=M.ABAVKAUFKRS AND R.FDAUFLFD=M.ABAVKAUFLFD AND R.FDAUFPOS=M.ABAVKAUFPOS AND ABAART=FDART AND  "
                    + " ABAVAR =FDVAR AND  ABAFARBE= FDFARBE  AND ABAGROE=FDGROE JOIN ABPOS P ON ABPSPGRD<='89' AND"
                    + " P.ABPAUFKRS=R.FDAUFKRS AND P.ABPAUFLFD=R.FDAUFLFD AND P.ABPAUFPOS=R.FDAUFPOS LEFT JOIN FSSTAMM S"
                    + " ON R.FDART=S.FSART AND R.FDVAR=S.FSVAR  "
                    + " WHERE  ABAART LIKE '%"+art.Trim()+"%' AND FDMANDANT=:FDMANDANT  AND FDTYP=:FDTYP AND FDSA=:FDSA AND FDZUGET=0 AND FDRESERV=0 AND M.ABAAUFTYP='N'"
                        //''+" AND FDART LIKE 'B140100115%' "
                    + " GROUP BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF,M.ABPART"
                    + " ORDER BY FDMANDANT,FDTYP,FDART,FDVAR,FDFARBE,FDGROE,ABACOLORREF"
                    + " ) A   LEFT JOIN FSFARBEN C ON A.ART=FSFART AND A.VAR=FSFVAR AND A.COLOR=C.FSFFARBE"
                    + " LEFT JOIN FSEINK K ON A.ART=K.FEART AND A.VAR=K.FEVAR "
                    + " LEFT JOIN LIEFDAT SP ON FELIEFNR=SP.LSLIEFNR";

                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDTYP", OracleType.NVarChar).Value = dwData["FDTYP"].ToString();
                    or1.Parameters.Add("FDSA", OracleType.NVarChar).Value = dwData["FDSA"].ToString();
                    break;

                case 99:
                    or1.CommandText = "SELECT 	FDMANDANT,FDTYP,FDAUFKRS,FDAUFLFD,FDAUFPOS,SUBSTR(FDSETPOS,2,2) AS FDUPOS,FDART,FDVAR,FDFARBE"
                    + ",FSABEZ AS ARTDES,FSFABEZ AS CDES,FDGROE,FDMENGE,FDZUGET,FDFREIG,FDVERBR,	FDRESERV,0 AS RATIO"
                        + " FROM FDECK  "
                        + " LEFT JOIN FSSTAMM ON FSART=FDART AND FSVAR=FDVAR"
                        + " LEFT JOIN FSFARBEN ON FSFART=FDART AND FSFVAR=FDVAR AND FSFFARBE=FDFARBE  "
                        + " WHERE FDMANDANT=:FDMANDANT AND FDSA='V' AND FDTYP='B' AND FDAUFKRS=:FDAUFKRS  AND FDAUFLFD=:FDAUFLFD"
                        + " ORDER BY FDART,FDVAR,FDFARBE,FDGROE";
                    or1.Parameters.Add("FDMANDANT", OracleType.NVarChar).Value = dwData["FDMANDANT"].ToString();
                    or1.Parameters.Add("FDAUFKRS", OracleType.NVarChar).Value = dwData["FDAUFKRS"].ToString();
                    or1.Parameters.Add("FDAUFLFD", OracleType.NVarChar).Value = dwData["FDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "FDECK";
            Return = Result;
            return Return;
        }
        public DataSet QueryFSZSTECH(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSZSTECH  "
                    + " WHERE FSZSMANDANT=:FSZSMANDANT AND FSZSFORM=:FSZSFORM";
                    or1.Parameters.Add("FSZSMANDANT", OracleType.NVarChar).Value = dwData["FSZSMANDANT"].ToString();
                    or1.Parameters.Add("FSZSFORM", OracleType.NVarChar).Value = dwData["FSZSFORM"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSZSTECH  "
                    + " WHERE FSZSMANDANT=:FSZSMANDANT AND FSZSFORM=:FSZSFORM";
                    or1.Parameters.Add("FSZSMANDANT", OracleType.NVarChar).Value = dwData["FSZSMANDANT"].ToString();
                    or1.Parameters.Add("FSZSFORM", OracleType.NVarChar).Value = dwData["FSZSFORM"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSZSTECH";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSSTUELI(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSSTUELI  "
                    + " WHERE FSSMANDANT=:FSSMANDANT AND FSSART=:FSSART AND FSSPOS=:FSSPOS";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSART", OracleType.NVarChar).Value = dwData["FSSART"].ToString();
                    or1.Parameters.Add("FSSPOS", OracleType.NVarChar).Value = dwData["FSSPOS"].ToString();
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSSTUELI  "
                    + " WHERE FSSMANDANT=:FSSMANDANT AND FSSART=:FSSART ";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSART", OracleType.NVarChar).Value = dwData["FSSART"].ToString();
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT S.*,P.TXTKTEXT,WAUEBM,WAFGRLFD FROM FSSTUELI S  LEFT JOIN TXTIND K ON FSSART||SUBSTR('0000'||FSSPOS,-4)= TRIM(TXTISIND)"
                        + " LEFT JOIN TXTKON P ON TXTKPIND=TXTIPIND  AND TXTKPOS=10"
                        + "  LEFT JOIN WASTAMM ON FSSMART=WAART AND FSSMVAR=WAVAR "
                        + "  WHERE FSSMANDANT=:FSSMANDANT AND FSSART=:FSSART";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSART", OracleType.NVarChar).Value = dwData["FSSART"].ToString();
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT FSABEZ,M.* FROM FSSTUELI M JOIN  FSSTAMM ON FSSART=FSART"
                    + " WHERE FSSMANDANT=:FSSMANDANT AND FSSMART=:FSSMART ";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    break;
                case 5:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT F.* FROM FSSTUELI F JOIN ABPOS ON ABPART=FSSART "
                    + " WHERE ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                case 6:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSSTUELI  "
                    + " WHERE FSSMANDANT=:FSSMANDANT AND FSSART=:FSSART  AND FSSMART=:FSSMART";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSART", OracleType.NVarChar).Value = dwData["FSSART"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                case 7:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT FSSZUSCHN,FSSZUSCHN AS FDES FROM FSSTUELI";
                    //FSSMANDANT	FSSART	FSSPOS 
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSSTUELI";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSSTAMM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM FSSTAMM  "
                    + " WHERE FSMANDANT=:FSMANDANT AND FSART=:FSART AND FSVAR=:FSVAR";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    or1.Parameters.Add("FSVAR", OracleType.NVarChar).Value = dwData["FSVAR"].ToString();
                    //FFSMANDANT	FSART	FSVAR 
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSSTAMM  "
                    + " WHERE FSMANDANT=:FSMANDANT AND FSART=:FSART";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT FSART,FSABEZ FROM FSSTAMM  "
                    + " WHERE FSMANDANT=:FSMANDANT AND FSART LIKE '2%' ";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    string FSART = dwData["FSART"].ToString().Trim();
                    or1.CommandText = "SELECT FSMANDANT,FSART,FSVAR,FSABEZ FROM FSSTAMM  "
                    + " WHERE FSMANDANT=:FSMANDANT AND FSART LIKE '" + FSART + "%' ORDER BY 1,2,3";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    //or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    break;
                case 5:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT FSMANDANT,FSART,FSVAR,FSABEZ FROM FSSTUELI S JOIN FSSTAMM M ON FSSART=M.FSART"
                        + " WHERE FSSMANDANT=:FSSMANDANT AND  S.FSSMART=:FSSMART ORDER BY 1,2,3";
                    or1.Parameters.Add("FSSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    break;
                case 6:
                    or1 = OracleDB.CreateCommand();
                    string s = dwData["FSSART"].ToString().Trim();
                    or1.CommandText = "SELECT DISTINCT FSMANDANT,FSART,FSVAR,FSABEZ FROM FSSTAMM JOIN FSSTUELI ON FSSART=FSART "
                    + " WHERE FSMANDANT=:FSMANDANT AND FSSART LIKE '" + s + "%'  AND FSSMART=:FSSMART ORDER BY 1,2,3";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSSMANDANT"].ToString();
                    or1.Parameters.Add("FSSMART", OracleType.NVarChar).Value = dwData["FSSMART"].ToString();
                    //or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT MAX(FSKOLL) AS FSKOLL FROM FSSTAMM  "
                    + " WHERE FSMANDANT=:FSMANDANT";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    //FFSMANDANT	FSART	FSVAR 
                    break;
                case 8:
                    or1.CommandText = "SELECT DISTINCT F.* FROM FSSTAMM F  RIGHT JOIN ABPOS ON ABPMANDANT=FSMANDANT AND FSART=ABPART"
                    + " WHERE ABPMANDANT=:ABPMANDANT AND ABPART=:ABPART AND ABPVAR=:ABPVAR";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABPVAR", OracleType.NVarChar).Value = dwData["ABPVAR"].ToString();
                    //FFSMANDANT	FSART	FSVAR 
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSSTAMM";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSRASTER(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSRASTER  "
                    + " WHERE FSRMANDANT=:FSRMANDANT AND FSRGRRAS=:FSRGRRAS";
                    or1.Parameters.Add("FSRMANDANT", OracleType.NVarChar).Value = dwData["FSRMANDANT"].ToString();
                    or1.Parameters.Add("FSRGRRAS", OracleType.NVarChar).Value = dwData["FSRGRRAS"].ToString();

                    //FSRMANDANT	FSRGRRAS

                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSRASTER  "
                    + " WHERE FSRMANDANT=:FSRMANDANT";
                    or1.Parameters.Add("FSRMANDANT", OracleType.NVarChar).Value = dwData["FSRMANDANT"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSRASTER";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSGROE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSGROE  "
                    + " WHERE FSGMANDANT=:FSGMANDANT AND FSGART=:FSGART AND  FSGVAR=:FSGVAR AND FSGGROE=:FSGGROE ";
                    or1.Parameters.Add("FSGMANDANT", OracleType.NVarChar).Value = dwData["FSGMANDANT"].ToString();
                    or1.Parameters.Add("FSGART", OracleType.NVarChar).Value = dwData["FSGART"].ToString();
                    or1.Parameters.Add("FSGVAR", OracleType.NVarChar).Value = dwData["FSGVAR"].ToString();
                    or1.Parameters.Add("FSGGROE", OracleType.NVarChar).Value = dwData["FSGGROE"].ToString();
                    //FSGMANDANT	FSGART	FSGVAR	FSGGROE 
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSGROE  "
                    + " WHERE FSGMANDANT=:FSGMANDANT AND FSGART=:FSGART AND  FSGVAR=:FSGVAR ";
                    or1.Parameters.Add("FSGMANDANT", OracleType.NVarChar).Value = dwData["FSGMANDANT"].ToString();
                    or1.Parameters.Add("FSGART", OracleType.NVarChar).Value = dwData["FSGART"].ToString();
                    or1.Parameters.Add("FSGVAR", OracleType.NVarChar).Value = dwData["FSGVAR"].ToString();
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSGROE  "
                    + " WHERE FSGMANDANT=:FSGMANDANT AND FSGART=:FSGART ";
                    or1.Parameters.Add("FSGMANDANT", OracleType.NVarChar).Value = dwData["FSGMANDANT"].ToString();
                    or1.Parameters.Add("FSGART", OracleType.NVarChar).Value = dwData["FSGART"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSGROE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSFTTECH(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFTTECH  "
                    + " WHERE FSFTMANDANT=:FSFTMANDANT AND FSFTZFORM=:FSFTZFORM AND  FSFTFORM=:FSFTFORM ";
                    or1.Parameters.Add("FSFTMANDANT", OracleType.NVarChar).Value = dwData["FSFTMANDANT"].ToString();
                    or1.Parameters.Add("FSFTZFORM", OracleType.NVarChar).Value = dwData["FSFTZFORM"].ToString();
                    or1.Parameters.Add("FSFTFORM", OracleType.NVarChar).Value = dwData["FSFTFORM"].ToString();
                    //FSFTMANDANT	FSFTZFORM	FSFTFORM
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFTTECH  "
                    + " WHERE FSFTMANDANT=:FSFTMANDANT AND FSFTZFORM=:FSFTZFORM AND  FSFTFORM=:FSFTFORM ";
                    or1.Parameters.Add("FSFTMANDANT", OracleType.NVarChar).Value = dwData["FSFTMANDANT"].ToString();
                    or1.Parameters.Add("FSFTZFORM", OracleType.NVarChar).Value = dwData["FSFTZFORM"].ToString();
                    or1.Parameters.Add("FSFTFORM", OracleType.NVarChar).Value = dwData["FSFTFORM"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSFTTECH";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSFOLGE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFOLGE  "
                    + " WHERE FSOMANDANT=:FSOMANDANT AND FSOART=:FSOART AND  FSOPOS=:FSOPOS ";
                    or1.Parameters.Add("FSOMANDANT", OracleType.NVarChar).Value = dwData["FSOMANDANT"].ToString();
                    or1.Parameters.Add("FSOART", OracleType.NVarChar).Value = dwData["FSOART"].ToString();
                    or1.Parameters.Add("FSOPOS", OracleType.NVarChar).Value = dwData["FSOPOS"].ToString();
                    //FSOMANDANT	FSOART	FSOPOS
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFOLGE  "
                    + " WHERE FSOMANDANT=:FSOMANDANT AND FSOART=:FSOART ";
                    or1.Parameters.Add("FSOMANDANT", OracleType.NVarChar).Value = dwData["FSOMANDANT"].ToString();
                    or1.Parameters.Add("FSOART", OracleType.NVarChar).Value = dwData["FSOART"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSFOLGE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSFARBEN(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART AND  FSFVAR=:FSFVAR AND FSFFARBE=:FSFFARBE ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    or1.Parameters.Add("FSFVAR", OracleType.NVarChar).Value = dwData["FSFVAR"].ToString();
                    or1.Parameters.Add("FSFFARBE", OracleType.NVarChar).Value = dwData["FSFFARBE"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART AND  FSFVAR=:FSFVAR ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    or1.Parameters.Add("FSFVAR", OracleType.NVarChar).Value = dwData["FSFVAR"].ToString();
                    break;
                case 3:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSFARBEN  "
                    + " WHERE FSFMANDANT=:FSFMANDANT AND FSFART=:FSFART ";
                    or1.Parameters.Add("FSFMANDANT", OracleType.NVarChar).Value = dwData["FSFMANDANT"].ToString();
                    or1.Parameters.Add("FSFART", OracleType.NVarChar).Value = dwData["FSFART"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSFARBEN";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSEINK(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSEINK  "
                    + " WHERE FEMANDANT=:FEMANDANT "
                    + " order by FEART DESC, FEFARBE DESC,FEGROE DESC";
                    or1.Parameters.Add("FEMANDANT", OracleType.NVarChar).Value = dwData["FEMANDANT"].ToString();
                    break;
                case 2:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSEINK  "
                    + " WHERE FEMANDANT=:FEMANDANT AND FEART=:FEART  AND FEVAR=:FEVAR";
                    or1.Parameters.Add("FEMANDANT", OracleType.NVarChar).Value = dwData["FEMANDANT"].ToString();
                    or1.Parameters.Add("FEART", OracleType.NVarChar).Value = dwData["FEART"].ToString();
                    or1.Parameters.Add("FEVAR", OracleType.NVarChar).Value = dwData["FEVAR"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSEINK";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryFSEGROE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            switch (option)
            {
                case 1:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT * FROM FSEGROE  "
                    + " WHERE FSEMANDANT=:FSEMANDANT ";
                    or1.Parameters.Add("FSEMANDANT", OracleType.NVarChar).Value = dwData["FSEMANDANT"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "FSEGROE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======G==============

        public DataSet QueryGPDAT(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GPDAT WHERE  "
                    + "  GPMANDANT=:GPMANDANT AND GPPARTIE=:GPPARTIE";
                    or1.Parameters.Add("GPMANDANT", OracleType.NVarChar).Value = dwData["GPMANDANT"].ToString();
                    or1.Parameters.Add("GPPARTIE", OracleType.NVarChar).Value = dwData["GPPARTIE"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM GPDAT WHERE  "
                        + "  GPMANDANT=:GPMANDANT AND GPPARTIE=:GPPARTIE";
                    or1.Parameters.Add("GPMANDANT", OracleType.NVarChar).Value = dwData["GPMANDANT"].ToString();
                    or1.Parameters.Add("GPPARTIE", OracleType.NVarChar).Value = dwData["GPPARTIE"].ToString();
                    break;
                case 4:
                    or1.CommandText = " SELECT DISTINCT GP.* FROM ZUTEI RIGHT JOIN GPDAT GP ON ZUMANDANT=GPMANDANT AND ZUPARTIE=GPPARTIE"
                    + " WHERE  ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD"; ;
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GPDAT";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGSCOLOR(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:

                    or1.CommandText = "SELECT * FROM GSCOLOR WHERE  "
                    + "  GSCMANDANT=:GSCMANDANT AND GSCART=:GSCART AND GSCVAR=:GSCVAR AND GSCFARBE=:GSCFARBE  ";
                    or1.Parameters.Add("GSCMANDANT", OracleType.NVarChar).Value = dwData["GSCMANDANT"].ToString();
                    or1.Parameters.Add("GSCART", OracleType.NVarChar).Value = dwData["GSCART"].ToString();
                    or1.Parameters.Add("GSCVAR", OracleType.NVarChar).Value = dwData["GSCVAR"].ToString();
                    or1.Parameters.Add("GSCFARBE", OracleType.NVarChar).Value = dwData["GSCFARBE"].ToString(); ;
                    break;
                case 3:
                    or1.CommandText = " SELECT DISTINCT GS.* FROM EKPOS GA LEFT JOIN GSCOLOR GS ON EKPMANDANT=GSCMANDANT "
                        + "  AND  utl_raw.cast_to_varchar2(EKPART)=GSCART AND  utl_raw.cast_to_varchar2(EKPVAR)=GSCVAR AND utl_raw.cast_to_varchar2(EKPFARBE)=GSCFARBE "
                        + "  WHERE EKPSA='PO' AND EKPARTGR=1 AND EKPMANDANT=:EKPMANDANT AND  EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "  SELECT DISTINCT GS.* FROM GAAUF GA RIGHT JOIN GSCOLOR GS ON GAMANDANT=GSCMANDANT"
                        + " AND GAART=GSCART AND GAVAR=GSCVAR AND GAFARBE=GSCFARBE "
                        + "  WHERE GAMANDANT=:GAMANDANT AND  GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD ";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;
                case 2:
                default:
                    or1.CommandText = "SELECT * FROM GSCOLOR WHERE  "
                    + "  GSCMANDANT=:GSCMANDANT AND GSCART=:GSCART AND GSCVAR=:GSCVAR AND GSCFARBE=:GSCFARBE  ";
                    or1.Parameters.Add("GSCMANDANT", OracleType.NVarChar).Value = dwData["GSCMANDANT"].ToString();
                    or1.Parameters.Add("GSCART", OracleType.NVarChar).Value = dwData["GSCART"].ToString();
                    or1.Parameters.Add("GSCVAR", OracleType.NVarChar).Value = dwData["GSCVAR"].ToString();
                    or1.Parameters.Add("GSCFARBE", OracleType.NVarChar).Value = dwData["GSCFARBE"].ToString(); ;

                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GSCOLOR";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGSDAT(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GSDAT WHERE  "
                    + "  GSMANDANT=:GSMANDANT AND GSART=:GSART AND GSVAR=:GSVAR";
                    or1.Parameters.Add("GSMANDANT", OracleType.NVarChar).Value = dwData["GSMANDANT"].ToString();
                    or1.Parameters.Add("GSART", OracleType.NVarChar).Value = dwData["GSART"].ToString();
                    or1.Parameters.Add("GSVAR", OracleType.NVarChar).Value = dwData["GSVAR"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT DISTINCT GS.* FROM EKPOS GA LEFT JOIN GSDAT GS ON EKPMANDANT=GSMANDANT   AND utl_raw.cast_to_varchar2(EKPART)=GSART"
                        + "  AND utl_raw.cast_to_varchar2(EKPVAR)=GSVAR"
                        + "  WHERE EKPSA='PO' AND EKPARTGR=1 AND EKPMANDANT=:EKPMANDANT AND  EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "  SELECT DISTINCT GS.* FROM GAAUF GA RIGHT JOIN GSDAT GS ON GAMANDANT=GSMANDANT"
                        + " AND GAART=GSART "
                        + "  WHERE GAMANDANT=:GAMANDANT AND  GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD ";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;

                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GSDAT";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGSDAT(string art, string var)
        {
            DataSet setReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM GSDAT WHERE  "
            + "  GSMANDANT=:GSMANDANT AND GSART=:GSART AND GSVAR=:GSVAR";
            or1.Parameters.Add("GSMANDANT", OracleType.NVarChar).Value = "00";
            or1.Parameters.Add("GSART", OracleType.NVarChar).Value = art;
            or1.Parameters.Add("GSVAR", OracleType.NVarChar).Value = var;
            SResult = Connect2Proxy(or1);
            if (SResult.Tables.Count > 0)
            {
                tbLocal = SResult.Tables[0];
                tbLocal.TableName = "GSDAT";
            }
            setReturn.Merge(SResult);
            return setReturn;
        }
        public DataSet QueryGSMATK(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GSMATK WHERE  "
                    + "  GSMMANDANT=:GSMMANDANT AND GSMART=:GSMART AND GSMVAR=:GSMVAR";
                    or1.Parameters.Add("GSMMANDANT", OracleType.NVarChar).Value = dwData["GSMMANDANT"].ToString();
                    or1.Parameters.Add("GSMART", OracleType.NVarChar).Value = dwData["GSMART"].ToString();
                    or1.Parameters.Add("GSMVAR", OracleType.NVarChar).Value = dwData["GSMVAR"].ToString();
                    break;
                case 4:
                    or1.CommandText = "  SELECT DISTINCT GS.* FROM GAAUF GA RIGHT JOIN GSMATK GS ON GAMANDANT=GSMMANDANT"
                        + " AND GAART=GSMART "
                        + "  WHERE GAMANDANT=:GAMANDANT AND  GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD ";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;
                case 2:
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GSMATK";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGAAUF(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GAAUF WHERE  "
                            + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS AND GASA=:GASA AND GAPOS=:GAPOS";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwData["GAAUFPOS"].ToString();
                    or1.Parameters.Add("GASA", OracleType.NVarChar).Value = dwData["GASA"].ToString();
                    or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwData["GAPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM GAAUF WHERE  "
                        + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwData["GAAUFPOS"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM GAAUF WHERE GAKG3>0 AND GASA=713 AND "
                        + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM GAAUF WHERE  "
                        + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;

                case 9:
                    or1.CommandText = "SELECT * FROM INTEX.GAAUF R WHERE NOT EXISTS"
                        + " (SELECT 1 FROM ICC_ABAUFM M  WHERE R.GAAUFKRS=M.ABAVKAUFKRS AND R.GAAUFLFD=M.ABAVKAUFLFD AND R.GAAUFPOS=M.ABAVKAUFPOS)"
                        + " AND GAMANDANT=:GAMANDANT AND GASA=:GASA AND GAKG2=0 AND GAKG3=0";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GASA", OracleType.NVarChar).Value = dwData["GASA"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM GAAUF WHERE  "
                            + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS  AND GAPOS=:GAPOS";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwData["GAAUFPOS"].ToString();
                    or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwData["GAPOS"].ToString();
                    break;
                case 99:
                    or1.CommandText = "SELECT GAAUFKRS,	GAAUFLFD,GAAUFPOS,GAART,GAVAR,GAFARBE,GAKG1,GAKG2,GAKG3,GAKG4,GAKG5,GAKG6,GAKG7"
                        + " FROM GAAUF WHERE  "
                        + "  GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwData["GAMANDANT"].ToString();
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwData["GAAUFKRS"].ToString();
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwData["GAAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GAAUF";
            }

            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGASTGA(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GASTGA WHERE  "
                            + "  GAGMANDANT=:GAGMANDANT AND GAGART=:GAGART AND GAGVAR=:GAGVAR AND GAGFARBE=:GAGFARBE AND GAGPOS=:GAGPOS";
                    or1.Parameters.Add("GAGMANDANT", OracleType.NVarChar).Value = dwData["GAGMANDANT"].ToString();
                    or1.Parameters.Add("GAGART", OracleType.NVarChar).Value = dwData["GAGART"].ToString();
                    or1.Parameters.Add("GAGVAR", OracleType.NVarChar).Value = dwData["GAGVAR"].ToString();
                    or1.Parameters.Add("GAGFARBE", OracleType.NVarChar).Value = dwData["GAGFARBE"].ToString();
                    or1.Parameters.Add("GAGPOS", OracleType.NVarChar).Value = dwData["GAGPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM GASTGA WHERE  "
                            + "  GAGMANDANT=:GAGMANDANT AND GAGART=:GAGART";
                    or1.Parameters.Add("GAGMANDANT", OracleType.NVarChar).Value = dwData["GAGMANDANT"].ToString();
                    or1.Parameters.Add("GAGART", OracleType.NVarChar).Value = dwData["GAGART"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GASTGA";
            }

            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGZKON(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM GZKON WHERE  "
                            + "  GZKMANDANT=:GZKMANDANT AND GZKART=:GZKART AND GZKVAR=:GZKVAR AND GZKFARBE=:GZKFARBE AND GZKPOS=:GZKPOS";
                    or1.Parameters.Add("GZKMANDANT", OracleType.NVarChar).Value = dwData["GZKMANDANT"].ToString();
                    or1.Parameters.Add("GZKART", OracleType.NVarChar).Value = dwData["GZKART"].ToString();
                    or1.Parameters.Add("GZKVAR", OracleType.NVarChar).Value = dwData["GZKVAR"].ToString();
                    or1.Parameters.Add("GZKFARBE", OracleType.NVarChar).Value = dwData["GZKFARBE"].ToString();
                    or1.Parameters.Add("GZKPOS", OracleType.NVarChar).Value = dwData["GZKPOS"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GASTGA";
            }

            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryGASTGA(string yart, string yvar, string ycolor)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM GASTGA WHERE  "
                + "  GAGMANDANT=:GAGMANDANT AND GAGART=:GAGART AND GAGVAR=:GAGVAR AND GAGFARBE=:GAGFARBE";
            or1.Parameters.Add("GAGMANDANT", OracleType.NVarChar).Value = "00";
            or1.Parameters.Add("GAGART", OracleType.NVarChar).Value = yart;
            or1.Parameters.Add("GAGVAR", OracleType.NVarChar).Value = yvar;
            or1.Parameters.Add("GAGFARBE", OracleType.NVarChar).Value = ycolor;

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GASTGA";
            }

            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryGASTGA(string yart)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT GAGART,GAGVAR,GAGFARBE FROM GASTGA WHERE  "
                + "  GAGMANDANT=:GAGMANDANT AND GAGART=:GAGART";
            or1.Parameters.Add("GAGMANDANT", OracleType.NVarChar).Value = "00";
            or1.Parameters.Add("GAGART", OracleType.NVarChar).Value = yart;
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GASTGA";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        public DataSet QueryGLLG(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT DISTINCT GP.* FROM ZUTEI RIGHT JOIN GPDAT GP ON ZUMANDANT=GPMANDANT AND ZUPARTIE=GPPARTIE"
                    + " WHERE  ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD"; ;
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "GPDAT";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======H==============
        public DataSet QueryHRSTAMM(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            // GSCMANDANT GSCART GSCVAR GSCFARBE


            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT AND HRBENID=:HRBENID AND HRDFAX=:HRDFAX";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    or1.Parameters.Add("HRBENID", OracleType.NVarChar).Value = dwData["HRBENID"].ToString();
                    or1.Parameters.Add("HRDFAX", OracleType.NVarChar).Value = dwData["HRDFAX"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT AND HRBENID=:HRBENID";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    or1.Parameters.Add("HRBENID", OracleType.NVarChar).Value = dwData["HRBENID"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT HRBENID,HRVNAME,HRNNAME FROM HRSTAMM";
                    break;
                case 4:
                    or1.CommandText = "SELECT HRBENID,HRVNAME,HRNNAME FROM HRSTAMM WHERE HRMANDANT=:HRMANDANT ";
                    or1.Parameters.Add("HRMANDANT", OracleType.NVarChar).Value = dwData["HRMANDANT"].ToString();
                    break;
                default:
                    break;
            }
            SResult = Connect2Proxy(or1);
            if (SResult.Tables.Count > 0)
            {
                tbLocal = SResult.Tables[0];
                tbLocal.TableName = "HRSTAMM";
            }
            SReturn.Merge(SResult);
            return SReturn;
        }
        #endregion
        #region======K==============
        public DataSet QueryKDSTAMM(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "KDSTAMM";
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM KDSTAMM WHERE  "
                            + "  KDMANDANT=:KDMANDANT AND KDKUNDNR=:KDKUNDNR";
                        or1.Parameters.Add("KDMANDANT", OracleType.NVarChar).Value = dwData["KDMANDANT"].ToString();
                        or1.Parameters.Add("KDKUNDNR", OracleType.NVarChar).Value = dwData["KDKUNDNR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT KDMANDANT,KDKUNDNR,KDKUNDNA,KDNAME1, KDSTRASSE1,KDKNAME,KDTEL,KDTELEX,KDFAX"
                        + " FROM KDSTAMM WHERE KDMANDANT=:KDMANDANT";
                        or1.Parameters.Add("KDMANDANT", OracleType.NVarChar).Value = dwData["KDMANDANT"].ToString();
                        break;
                    case -1:
                        or1.CommandText = "SELECT MAX(KDKUNDNR) AS KDKUNDNR FROM KDSTAMM WHERE KDMANDANT=:KDMANDANT";
                        or1.Parameters.Add("KDMANDANT", OracleType.NVarChar).Value = dwData["KDMANDANT"].ToString();
                        break;
                    default:
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "KDSTAMM";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryKUNDADR(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM KUNDADR   WHERE "
                                + " KDAKUNDNR = :KDAKUNDNR";
                        or1.Parameters.Add("KDAKUNDNR", OracleType.NVarChar).Value = dwData["KDAKUNDNR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT KR.* FROM VVLIEF JOIN KUNDADR   KR ON VVKUNDNRE= KDAKUNDNR AND KDAADRSL=VVADRSLL "
                        + " WHERE VVMANDANT=:VVMANDANT AND VVLIEFSCH = :VVLIEFSCH";
                        or1.Parameters.Add("VVMANDANT", OracleType.NVarChar).Value = dwData["VVMANDANT"].ToString();
                        or1.Parameters.Add("VVLIEFSCH", OracleType.NVarChar).Value = dwData["VVLIEFSCH"].ToString();
                        break;
                    default:
                        break;
                }

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "KUNDADR";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryKDANSP(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM KDANSP   WHERE "
                                                + " KDSKUNDNR = :KDSKUNDNR";
                or1.Parameters.Add("KDSKUNDNR", OracleType.NVarChar).Value = dwData["KDSKUNDNR"].ToString();
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "KDANSP";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryKUNDVER(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 2:
                        or1.CommandText = "SELECT * FROM KUNDVER WHERE  "
                            + "  KDVMANDANT=:KDVMANDANT AND KDVKUNDNR=:KDVKUNDNR";
                        or1.Parameters.Add("KDVMANDANT", OracleType.NVarChar).Value = dwData["KDVMANDANT"].ToString();
                        or1.Parameters.Add("KDVKUNDNR", OracleType.NVarChar).Value = dwData["KDVKUNDNR"].ToString();
                        break;
                    case 1:
                    default:
                        or1.CommandText = "SELECT * FROM KUNDVER WHERE  "
                            + "  KDVMANDANT=:KDVMANDANT AND KDVKUNDNR=:KDVKUNDNR AND KDVVB=:KDVVB AND KDVVG=:KDVVG";
                        or1.Parameters.Add("KDVMANDANT", OracleType.NVarChar).Value = dwData["KDVMANDANT"].ToString();
                        or1.Parameters.Add("KDVKUNDNR", OracleType.NVarChar).Value = dwData["KDVKUNDNR"].ToString();
                        or1.Parameters.Add("KDVVB", OracleType.NVarChar).Value = dwData["KDVVB"].ToString();
                        or1.Parameters.Add("KDVVG", OracleType.NVarChar).Value = dwData["KDVVG"].ToString();
                        break;
                }

                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "KUNDVER";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryKSTAGZUO(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM KSTAGZUO WHERE  "
                            + "  KSZMANDANT=:KSZMANDANT AND KSZLIEFNR=:KSZLIEFNR";
                        or1.Parameters.Add("KSZMANDANT", OracleType.NVarChar).Value = dwData["KSZMANDANT"].ToString();
                        or1.Parameters.Add("KSZLIEFNR", OracleType.NVarChar).Value = dwData["KSZLIEFNR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT DISTINCT KSZMANDANT, KSZKSTKRS,KSZKST,KSZAGANG, KSZLO,KSZLB,KSZLP FROM KSTAGZUO WHERE  "
                            + "  KSZMANDANT=:KSZMANDANT";
                        or1.Parameters.Add("KSZMANDANT", OracleType.NVarChar).Value = dwData["KSZMANDANT"].ToString();
                        break;
                    default:
                        break;
                }

                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "KSTAGZUO";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryKSLEIST(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM KSLEIST WHERE  "
                            + "  KSLMANDANT=:KSLMANDANT AND KSLAUFKRS=:KSLAUFKRS AND KSLAUFLFD=:KSLAUFLFD AND KSLAUFPOS=:KSLAUFPOS AND KSLAFOLGE=:KSLAFOLGE AND KSLAENDZL=:KSLAENDZL";
                        or1.Parameters.Add("KSLMANDANT", OracleType.NVarChar).Value = dwData["KSLMANDANT"].ToString();
                        or1.Parameters.Add("KSLAUFKRS", OracleType.NVarChar).Value = dwData["KSLAUFKRS"].ToString();
                        or1.Parameters.Add("KSLAUFLFD", OracleType.NVarChar).Value = dwData["KSLAUFLFD"].ToString();
                        or1.Parameters.Add("KSLAUFPOS", OracleType.NVarChar).Value = dwData["KSLAUFPOS"].ToString();
                        or1.Parameters.Add("KSLAFOLGE", OracleType.NVarChar).Value = dwData["KSLAFOLGE"].ToString();
                        or1.Parameters.Add("KSLAENDZL", OracleType.NVarChar).Value = dwData["KSLAENDZL"].ToString();
                        break;
                    default:
                        break;
                }

                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "KSTAGZUO";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }

        #endregion
        #region======L==============
        public DataSet QueryLIEFDAT(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM LIEFDAT WHERE  "
                    + "  LSMANDANT=:LSMANDANT AND LSLIEFNR=:LSLIEFNR";
                    or1.Parameters.Add("LSMANDANT", OracleType.NVarChar).Value = dwData["LSMANDANT"].ToString();
                    or1.Parameters.Add("LSLIEFNR", OracleType.NVarChar).Value = dwData["LSLIEFNR"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM LIEFDAT WHERE  "
                    + "  LSMANDANT=:LSMANDANT AND LSLIEFNR=:LSLIEFNR";
                    or1.Parameters.Add("LSMANDANT", OracleType.NVarChar).Value = dwData["LSMANDANT"].ToString();
                    or1.Parameters.Add("LSLIEFNR", OracleType.NVarChar).Value = dwData["LSLIEFNR"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT LSLIEFNR,LSLIEFNA,RTRIM(LSLIEFNA)||RTRIM(LSNAME1)  AS LSNAME1  FROM LIEFDAT WHERE  "
                    + "  LSMANDANT=:LSMANDANT AND LSGRSCHL=:LSGRSCHL";
                    or1.Parameters.Add("LSMANDANT", OracleType.NVarChar).Value = dwData["LSMANDANT"].ToString();
                    or1.Parameters.Add("LSGRSCHL", OracleType.NVarChar).Value = dwData["LSGRSCHL"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT LF.* FROM ABFOLGE FL RIGHT JOIN LIEFDAT LF"
                        + " ON FL.ABFMANDANT=LSMANDANT AND FL.ABFLIEFNR=LSLIEFNR"
                        + " WHERE ABFMANDANT=:ABFMANDANT AND ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD";
                    or1.Parameters.Add("ABFMANDANT", OracleType.NVarChar).Value = dwData["ABFMANDANT"].ToString();
                    or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwData["ABFAUFKRS"].ToString();
                    or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwData["ABFAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT LF.* FROM EKKOPF FL JOIN LIEFDAT LF"
             + " ON FL.EKKMANDANT=LSMANDANT AND FL.EKKLIEFNR=LSLIEFNR"
             + " WHERE EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT LSLIEFNR,LSLIEFNA,LSNAME1 FROM LIEFDAT WHERE  "
                    + "  LSMANDANT=:LSMANDANT  ";
                    or1.Parameters.Add("LSMANDANT", OracleType.NVarChar).Value = dwData["LSMANDANT"].ToString();
                    break;
                default:
                    or1.CommandText = "SELECT * FROM LIEFDAT WHERE  "
                        + "  LSMANDANT=:LSMANDANT AND LSLIEFNR=:LSLIEFNR";
                    or1.Parameters.Add("LSMANDANT", OracleType.NVarChar).Value = dwData["LSMANDANT"].ToString();
                    or1.Parameters.Add("LSLIEFNR", OracleType.NVarChar).Value = dwData["LSLIEFNR"].ToString();
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "LIEFDAT";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryLIEFKO(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT LF.* FROM EKKOPF FL JOIN LIEFKO LF"
             + " ON FL.EKKMANDANT=LSKMANDANT AND FL.EKKLIEFNR=LSKLIEFNR"
             + " WHERE EKKMANDANT=:EKKMANDANT AND EKKAUFKRS=:EKKAUFKRS AND EKKAUFLFD=:EKKAUFLFD";
                    or1.Parameters.Add("EKKMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKKAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKKAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                default:

                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "LIEFKO";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryLOGINFO(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM LOGINFO WHERE FINTERID=:FINTERID";
                    or1.Parameters.Add("FINTERID", OracleType.NVarChar).Value = dwData["FINTERID"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM LOGINFO   WHERE SUBSTR('00000000000'||FINTERID,-10)=(SELECT MAX(SUBSTR('00000000000'||FINTERID,-10)) FROM LOGINFO)";
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    break;
                default:

                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "LogInfo";
            }
            setReturn.Merge(Result);
            return setReturn;
        }

        #endregion
        #region======M==============

        public DataSet QueryMSSTAMM(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM MSSTAMM  "
                    + " WHERE MSMANDANT=:MSMANDANT AND MSMAT=:MSMAT AND MSVAR=:MSVAR";
                    or1.Parameters.Add("MSMANDANT", OracleType.NVarChar).Value = dwData["MSMANDANT"].ToString();
                    or1.Parameters.Add("MSMAT", OracleType.NVarChar).Value = dwData["MSMAT"].ToString();
                    or1.Parameters.Add("MSVAR", OracleType.NVarChar).Value = dwData["MSVAR"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT DISTINCT GS.* FROM EKPOS GA RIGHT JOIN MSSTAMM GS ON EKPMANDANT=GSCMANDANT "
                        + "  AND cast_to_varchar2(EKPART)=SUBSTR(MSMAT||'                                         ',0,40) AND utl_raw.cast_to_varchar2(EKPVAR)=MSVAR  "
                        + "  WHERE  EKPSA='PO' AND EKPARTGR=8 AND EKPMANDANT=:EKPMANDANT AND  EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "MSSTAMM";
            Return = Result;
            return Return;
        }
        public DataSet QueryMSEINK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM MSEINK  "
                            + " WHERE MEMANDANT=:MEMANDANT AND MEMAT=:MEMAT AND MEVAR=:MEVAR";
                    or1.Parameters.Add("MEMANDANT", OracleType.NVarChar).Value = dwData["MEMANDANT"].ToString();
                    or1.Parameters.Add("MEMAT", OracleType.NVarChar).Value = dwData["MEMAT"].ToString();
                    or1.Parameters.Add("MEVAR", OracleType.NVarChar).Value = dwData["MEVAR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "MSEINK";
            Return = Result;
            return Return;
        }
        public DataSet QueryMSEINKL(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM MSEINKL  "
                            + " WHERE MSEMANDANT=:MSEMANDANT AND MSEMAT=:MSEMAT AND MSEVAR=:MSEVAR";
                    or1.Parameters.Add("MSEMANDANT", OracleType.NVarChar).Value = dwData["MSEMANDANT"].ToString();
                    or1.Parameters.Add("MSEMAT", OracleType.NVarChar).Value = dwData["MSEMAT"].ToString();
                    or1.Parameters.Add("MSEVAR", OracleType.NVarChar).Value = dwData["MSEVAR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "MSEINKL";
            Return = Result;
            return Return;
        }
        public DataSet QueryMBST(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM MBST  "
                            + " WHERE MBMANDANT=:MBMANDANT AND MBMAT=:MBMAT AND MBVAR=:MBVAR";
                    or1.Parameters.Add("MBMANDANT", OracleType.NVarChar).Value = dwData["MBMANDANT"].ToString();
                    or1.Parameters.Add("MBMAT", OracleType.NVarChar).Value = dwData["MBMAT"].ToString();
                    or1.Parameters.Add("MBVAR", OracleType.NVarChar).Value = dwData["MBVAR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "MBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryICC_MBST(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    or1.CommandText = "SELECT 1 AS BAID,MBMANDANT AS MANDANT"
                    + ",MBMAT AS ART,MBVAR AS VAR,MBLO AS LO,MBLB AS LB,MBLP AS LP,MBVPEINH AS LOT,MBME*0.001 AS QTY,0 AS QTYLOCKED,MBME*0.001 AS QTYFREE"
                    + " FROM MBST M  "
                    + " WHERE MBMANDANT=:MBMANDANT AND MBMAT=:MBMAT AND MBVAR=:MBVAR";
                    or1.Parameters.Add("MBMANDANT", OracleType.NVarChar).Value = dwData["MBMANDANT"].ToString();
                    or1.Parameters.Add("MBMAT", OracleType.NVarChar).Value = dwData["MBMAT"].ToString();
                    or1.Parameters.Add("MBVAR", OracleType.NVarChar).Value = dwData["MBVAR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_STOCK";
            Return = Result;
            return Return;
        }
        public DataSet QueryMDECK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM MDECK  "
                        + " WHERE MDMANDANT=:MDMANDANT AND WDTYP='B' AND MDAUFKRS=:MDAUFKRS  AND MDAUFLFD=:MDAUFLFD AND MDAUFPOS=:MDAUFPOS";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDAUFKRS", OracleType.NVarChar).Value = dwData["MDAUFKRS"].ToString();
                    or1.Parameters.Add("MDAUFLFD", OracleType.NVarChar).Value = dwData["MDAUFLFD"].ToString();
                    or1.Parameters.Add("MDAUFPOS", OracleType.NVarChar).Value = dwData["MDAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM MDECK  "
                        + " WHERE MDMANDANT=:MDMANDANT AND MDTYP=:MDTYP AND MDAUFKRS=:MDAUFKRS  AND MDAUFLFD=:MDAUFLFD AND MDAUFPOS=:MDAUFPOS AND MDRPOS=:MDRPOS";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDAUFKRS", OracleType.NVarChar).Value = dwData["MDAUFKRS"].ToString();
                    or1.Parameters.Add("MDAUFLFD", OracleType.NVarChar).Value = dwData["MDAUFLFD"].ToString();
                    or1.Parameters.Add("MDAUFPOS", OracleType.NVarChar).Value = dwData["MDAUFPOS"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    or1.Parameters.Add("MDRPOS", OracleType.NVarChar).Value = dwData["MDRPOS"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT DISTINCT ABKMANDANT, ABKAUFKRS,ABKAUFLFD,ABPART,FSABEZ,LSLIEFNA AS EXTPRODUCER,ABPLIEFNR,ABPANRKR,ABPALFDNR  "
                    + " FROM MDECK F "
                    + " JOIN ABKOPF K ON F.MDAUFKRS=K.ABKAUFKRS AND  F.MDAUFLFD=K.ABKAUFLFD"
                    + " JOIN ABPOS P ON F.MDAUFKRS=P.ABPAUFKRS AND  F.MDAUFLFD=P.ABPAUFLFD AND  F.MDAUFPOS=P.ABPAUFPOS  AND ABPGESSTA='SP'"
                    + " LEFT JOIN FSSTAMM M ON ABPART=FSART"
                        + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                    + " WHERE F.MDMAT=:MDMAT AND F.MDTYP=:MDTYP";
                    or1.Parameters.Add("MDMAT", OracleType.NVarChar).Value = dwData["MDMAT"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM MDECK  "
                        + " WHERE MDMANDANT=:MDMANDANT AND MDTYP='B' AND MDAUFKRS=:MDAUFKRS  AND MDAUFLFD=:MDAUFLFD";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDAUFKRS", OracleType.NVarChar).Value = dwData["MDAUFKRS"].ToString();
                    or1.Parameters.Add("MDAUFLFD", OracleType.NVarChar).Value = dwData["MDAUFLFD"].ToString();
                    break;
                case 8://按照原料的所有需求
                    or1.CommandText = "SELECT  DISTINCT R.* FROM INTEX.MDECK R JOIN"
                        + " INTEX.ICC_ABAUFM M  ON R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD AND R.MDAUFPOS=M.ABAVKAUFPOS AND TRIM(R.MDRPOS)=TRIM(M.ABAVKUPOS) "
                        + " WHERE MDMANDANT=:MDMANDANT  AND MDTYP=:MDTYP AND MDMAT=:MDMAT AND MDVAR=:MDVAR AND MDZUGET=0 AND MDRESERV=0"
                        + " AND M.ABAAUFTYP='N' ";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    or1.Parameters.Add("MDMAT", OracleType.NVarChar).Value = dwData["MDMAT"].ToString();
                    or1.Parameters.Add("MDVAR", OracleType.NVarChar).Value = dwData["MDVAR"].ToString();
                    break;
                case 9://分组
                    /*
               SELECT MDMANDANT AS MANDANT,MDTYP AS DTYP,MDMAT AS ART,MDVAR AS VAR,'          ' AS COLOR,
' ' AS CDES, '       ' AS ASIZE,
MDMEH AS UM,MAX(S.MSBEZ)AS ARTDES,SUM(ABARESMG) AS REQ,
MAX(LSLIEFNA) AS SELLER
FROM INTEX.MDECK R JOIN INTEX.ICC_ABAUFM M
ON R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD
AND R.MDAUFPOS=M.ABAVKAUFPOS  AND R.MDRPOS=M.ABAVKUPOS AND TRIM(ABAART)=TRIM(MDMAT) AND TRIM(ABAVAR)=TRIM(MDVAR)
LEFT JOIN MSSTAMM S ON R.MDMAT=S.MSMAT AND R.MDVAR=S.MSVAR
LEFT JOIN MSEINK K ON R.MDMAT=K.MEMAT AND R.MDVAR=K.MEVAR
LEFT JOIN LIEFDAT ON MELIEFNR=LSLIEFNR
 WHERE MDMANDANT='00'  AND MDTYP='B'
 AND MDZUGET=0 AND MDRESERV=0 AND M.ABAAUFTYP='N'
 GROUP BY MDMANDANT,MDTYP,MDMAT,MDVAR,MDMEH
 ORDER BY MDMANDANT,MDTYP,MDMAT,MDVAR,MDMEH
                     */
                    or1.CommandText = "SELECT MDMANDANT AS MANDANT,MDTYP AS DTYP,MDMAT AS ART,MDVAR AS VAR,'          ' AS COLOR,"
                        + "' ' AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MDMEH AS UM,MAX(Trim(S.MSBEZ))AS ARTDES,SUM(ABARESMG) AS REQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME "
                        + " FROM INTEX.MDECK R JOIN INTEX.ICC_ABAUFM M"
                        + " ON R.MDAUFKRS=M.ABAVKAUFKRS AND R.MDAUFLFD=M.ABAVKAUFLFD"
                        + " AND R.MDAUFPOS=M.ABAVKAUFPOS  AND R.MDRPOS=M.ABAVKUPOS AND TRIM(ABAART)=TRIM(MDMAT) AND TRIM(ABAVAR)=TRIM(MDVAR)"
                        + " LEFT JOIN MSSTAMM S ON R.MDMAT=S.MSMAT AND R.MDVAR=S.MSVAR"
                        + " LEFT JOIN MSEINK K ON R.MDMAT=K.MEMAT AND R.MDVAR=K.MEVAR"
                        + " LEFT JOIN LIEFDAT SP ON MELIEFNR=SP.LSLIEFNR"
                        + "  WHERE  MDMANDANT=:MDMANDANT  AND MDTYP=:MDTYP"
                        + " AND MDZUGET=0 AND MDRESERV=0 AND M.ABAAUFTYP='N'"
                        + " GROUP BY MDMANDANT,MDTYP,MDMAT,MDVAR,MDMEH,ABACOLORREF"
                        + " ORDER BY MDMANDANT,MDTYP,MDMAT,MDVAR,MDMEH,ABACOLORREF";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDTYP", OracleType.NVarChar).Value = dwData["MDTYP"].ToString();
                    break;
                case 99:
                    or1.CommandText = "SELECT 	MDAUFKRS,MDAUFLFD,MDAUFPOS,MDMAT,MDVAR,	MDMENGE,MDEINGET,	MDZUGET,	MDRESERV,MDVERBR,MDMEH,0 AS RATIO"
                        + " FROM MDECK  "
                        + " WHERE MDMANDANT=:MDMANDANT AND MDTYP='B' AND MDAUFKRS=:MDAUFKRS  AND MDAUFLFD=:MDAUFLFD";
                    or1.Parameters.Add("MDMANDANT", OracleType.NVarChar).Value = dwData["MDMANDANT"].ToString();
                    or1.Parameters.Add("MDAUFKRS", OracleType.NVarChar).Value = dwData["MDAUFKRS"].ToString();
                    or1.Parameters.Add("MDAUFLFD", OracleType.NVarChar).Value = dwData["MDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "MDECK";
            Return = Result;
            return Return;
        }
        #endregion
        #region======P==============
        #endregion
        #region======Q==============

        public DataSet QueryQPPROF(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 2:
                        or1.CommandText = " SELECT DISTINCT GS.* FROM EKPOS GA LEFT JOIN QPPROF GS ON EKPMANDANT=QAPMANDANT"
                        + " AND utl_raw.cast_to_varchar2(EKPART)=QAPART"
                        + "  AND utl_raw.cast_to_varchar2(EKPVAR)=QAPVAR"
                        + "  WHERE EKPSA='PO' AND EKPARTGR=1 AND EKPMANDANT=:EKPMANDANT AND  EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                        or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                        or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                        or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                        break;
                }

                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    SResult.Tables[0].TableName = "QPPROF";
                    SReturn.Merge(SResult);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }
        public DataSet QueryQPMERKM(DataRow dwData, int option = 1)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT *FROM QPMERKM ";
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "QPMERKM";
            }
            set4Return.Merge(Result);
            return set4Return;
        }
        public DataSet QueryQPZUORD(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();

            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT* FROM QPZUORD"
                            + " WHERE  QPZARTST='F' AND QPZART=:QPZART AND QPZVAR=:QPZVAR";
                        or1.Parameters.Add("QPZART", OracleType.NVarChar).Value = dwData["QPZART"].ToString();
                        or1.Parameters.Add("QPZVAR", OracleType.NVarChar).Value = dwData["QPZVAR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT* FROM QPZUORD"
                            + " WHERE QPZMANDANT=:QPZMANDANT AND QPZARTST='F' AND QPZPNRKRS=:QPZPNRKRS AND QPZPLFDNR=:QPZPLFDNR";
                        or1.Parameters.Add("QPZMANDANT", OracleType.NVarChar).Value = dwData["QPZMANDANT"].ToString();
                        or1.Parameters.Add("QPZPNRKRS", OracleType.NVarChar).Value = dwData["QPZPNRKRS"].ToString();
                        or1.Parameters.Add("QPZPLFDNR", OracleType.NVarChar).Value = dwData["QPZPLFDNR"].ToString();
                        break;
                    case 3:
                        or1.CommandText = "SELECT* FROM QPZUORD"
                            + " WHERE QPZMANDANT=:QPZMANDANT AND QPZARTST='F' AND QPZART=:QPZART AND QPZVAR=:QPZVAR AND QPZPNRKRS=:QPZPNRKRS AND QPZPLFDNR=:QPZPLFDNR";
                        or1.Parameters.Add("QPZMANDANT", OracleType.NVarChar).Value = dwData["QPZMANDANT"].ToString();
                        or1.Parameters.Add("QPZART", OracleType.NVarChar).Value = dwData["QPZART"].ToString();
                        or1.Parameters.Add("QPZVAR", OracleType.NVarChar).Value = dwData["QPZVAR"].ToString();
                        or1.Parameters.Add("QPZPNRKRS", OracleType.NVarChar).Value = dwData["QPZPNRKRS"].ToString();
                        or1.Parameters.Add("QPZPLFDNR", OracleType.NVarChar).Value = dwData["QPZPLFDNR"].ToString();
                        break;
                    default:
                        or1.CommandText = "SELECT* FROM QPZUORD"
                            + " WHERE  QPZARTST='F' AND QPZART=:QPZART AND QPZVAR=:QPZVAR";
                        or1.Parameters.Add("QPZART", OracleType.NVarChar).Value = dwData["QPZART"].ToString();
                        or1.Parameters.Add("QPZVAR", OracleType.NVarChar).Value = dwData["QPZVAR"].ToString();
                        break;
                }

                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    SResult.Tables[0].TableName = "QPZUORD";
                    SReturn.Merge(SResult);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }
        public DataSet QueryQPPLAN(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT* FROM QPPLAN"
                            + " WHERE  QPPSPGRD='  ' AND QPPPNRKRS=:QPPPNRKRS AND QPPPLFDNR=:QPPPLFDNR"
                               + " ORDER BY 1,2,3";
                        or1.Parameters.Add("QPPPNRKRS", OracleType.NVarChar).Value = dwData["QPPPNRKRS"].ToString();
                        or1.Parameters.Add("QPPPLFDNR", OracleType.NVarChar).Value = dwData["QPPPLFDNR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT* FROM QPPLAN"
                            + " WHERE   QPPSPGRD='  ' AND QPPMANDANT=:QPPMANDANT"
                            + " ORDER BY 1,2,3";
                        or1.Parameters.Add("QPPMANDANT", OracleType.NVarChar).Value = dwData["QPPMANDANT"].ToString();
                        break;
                    default:
                        or1.CommandText = "SELECT* FROM QPPLAN"
                            + " WHERE   QPPSPGRD='  ' AND QPPPNRKRS=:QPPPNRKRS AND QPPPLFDNR=:QPPPLFDNR"
                               + " ORDER BY 1,2,3";
                        or1.Parameters.Add("QPPPNRKRS", OracleType.NVarChar).Value = dwData["QPPPNRKRS"].ToString();
                        or1.Parameters.Add("QPPPLFDNR", OracleType.NVarChar).Value = dwData["QPPPLFDNR"].ToString();
                        break;
                }

                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    SResult.Tables[0].TableName = "QPPLAN";
                    SReturn.Merge(SResult);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }
        public DataSet QueryQPSTEP(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT M.QPMKURZB,M.QPMMEEH,M.QPMBEZ,S.* "
                            + " FROM QPSTEP S,QPMERKM M"
                            + " WHERE S.QPSMERKM=M.QPMMERKM "
                            + " AND     QPSPNRKRS=:QPSPNRKRS AND QPSPLFDNR=:QPSPLFDNR";
                        or1.Parameters.Add("QPSPNRKRS", OracleType.NVarChar).Value = dwData["QPSPNRKRS"].ToString();
                        or1.Parameters.Add("QPSPLFDNR", OracleType.NVarChar).Value = dwData["QPSPLFDNR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT M.QPMKURZB,M.QPMMEEH,M.QPMBEZ,QPMNORM,WAPBEM, WAPBIS,WAPME,WAPMIN,WAPMAX,S.*"
                            + "  FROM QPSTEP S LEFT JOIN QPMERKM M ON S.QPSMERKM=M.QPMMERKM"
                            + " LEFT JOIN WAPROF ON RTRIM(QPSMERKM)= RTRIM(WAPANFART)  AND WAPART=:WAPART AND WAPVAR=:WAPVAR"
                            + " WHERE QPSPNRKRS=:QPSPNRKRS AND  QPSPLFDNR=:QPSPLFDNR"
                            + " ORDER BY QPSSTEP";
                        or1.Parameters.Add("QPSPNRKRS", OracleType.NVarChar).Value = dwData["QPZPNRKRS"].ToString();
                        or1.Parameters.Add("QPSPLFDNR", OracleType.NVarChar).Value = dwData["QPZPLFDNR"].ToString();
                        or1.Parameters.Add("WAPART", OracleType.NVarChar).Value = dwData["QPZART"].ToString();
                        or1.Parameters.Add("WAPVAR", OracleType.NVarChar).Value = Left(dwData["QPZVAR"].ToString(), 2);
                        break;
                    default:
                        break;
                }
                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    SResult.Tables[0].TableName = "QPSTEP";
                }
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return SReturn;
        }
        #endregion
        #region======S==============
        public DataSet QuerySDDAT(DataRow dwSDDAT, int option = 1)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            DataTable tbLocal = null;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM SDDAT WHERE SDSA=:SDSA AND SDKEY =:SDKEY";
                    or1.Parameters.Add("SDSA", OracleType.NVarChar).Value = dwSDDAT["SDSA"].ToString(); ;
                    or1.Parameters.Add("SDKEY", OracleType.NVarChar).Value = dwSDDAT["SDKEY"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM SDDAT WHERE SDSA=:SDSA AND SDKEY =:SDKEY";
                    or1.Parameters.Add("SDSA", OracleType.NVarChar).Value = dwSDDAT["SDSA"].ToString();
                    or1.Parameters.Add("SDKEY", OracleType.NVarChar).Value = dwSDDAT["SDKEY"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT SDSA,SUBSTR(SDKEY,3,3)AS SDKEY,SUBSTR(SDDATEN,2,10) AS SDDATEN  FROM SDDAT WHERE SDSA=:SDSA"
                        + " AND SDKEY LIKE '%V'";
                    or1.Parameters.Add("SDSA", OracleType.NVarChar).Value = dwSDDAT["SDSA"].ToString();
                    break;
                case 9999:
                    or1.CommandText = "SELECT * FROM SDDAT WHERE SDSA=:SDSA";
                    or1.Parameters.Add("SDSA", OracleType.NVarChar).Value = dwSDDAT["SDSA"].ToString();
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "SDDAT";
                set4Return.Merge(Result);
            }
            return set4Return;
        }
        public DataSet QuerySTUELI(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM STUELI WHERE  "
                        + "  STUELIMANDANT=:STUELIMANDANT AND STUELISAPD=:STUELISAPD ";
                    or1.Parameters.Add("STUELIMANDANT", OracleType.NVarChar).Value = dwData["STUELIMANDANT"].ToString();
                    or1.Parameters.Add("STUELISAPD", OracleType.NVarChar).Value = dwData["STUELISAPD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM STUELI WHERE  "
        + "  STUELIMANDANT=:STUELIMANDANT AND STUELISAPD=:STUELISAPD ";
                    or1.Parameters.Add("STUELIMANDANT", OracleType.NVarChar).Value = dwData["STUELIMANDANT"].ToString();
                    or1.Parameters.Add("STUELISAPD", OracleType.NVarChar).Value = dwData["STUELISAPD"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT DISTINCT TRIM(SUBSTR(STUELISAPD,15,20)) AS C, DECODE(TRIM(SUBSTR(STUELIDATEN,55,2)),'R','XXX','FL','FACE:','GS','GROUND:') AS A,"
                        + "  TO_NUMBER(SUBSTR(STUELIDATEN,1,4))*0.1||'%'||TRIM(STUELISASB) AS B ,SUBSTR(STUELIDATEN,1,4) AS D"
                        + "    FROM STUELI WHERE SUBSTR(STUELIDATEN,55,2) IN ('R ','FL','GS')"
                        + "     AND STUELIMANDANT=:STUELIMANDANT AND SUBSTR(STUELISAPD,15,20)=:STUELISAPD  "
                        + " ORDER BY C,A,D DESC";
                    or1.Parameters.Add("STUELIMANDANT", OracleType.NVarChar).Value = dwData["STUELIMANDANT"].ToString();
                    or1.Parameters.Add("STUELISAPD", OracleType.NVarChar).Value = Left(dwData["STUELISAPD"].ToString(), 20);
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "STUELI";
            }

            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======T==============
        public DataSet QueryTXTKON(DataRow dwInput, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataTable tbLocal = null;

            try
            {

                or1 = OracleDB.CreateCommand();
                string key = "";
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT TRIM(TXTISIND) AS TXTISIND,TXTITXTART,TXTIPIND,TXTKPOS,TXTKTEXT"
                            + " FROM TXTIND T JOIN TXTKON ON TXTIMANDANT=TXTKMANDANT AND  TXTIPIND=TXTKPIND"
                            + " WHERE TXTIMANDANT=:TXTIMANDANT"
                           + " AND TXTISIND=:TXTISIND AND TXTITXTART=:TXTITXTART"
                            + " ORDER BY 1,2,3,4";
                        or1.Parameters.Add("TXTIMANDANT", OracleType.NVarChar).Value = dwInput["TXTIMANDANT"];
                        or1.Parameters.Add("TXTITXTART", OracleType.NVarChar).Value = dwInput["TXTITXTART"];
                        or1.Parameters.Add("TXTISIND", OracleType.NVarChar).Value = dwInput["TXTISIND"];
                        break;
                    case 2:
                        key = dwInput["TXTISIND"].ToString();
                        or1.CommandText = "SELECT TRIM(TXTISIND) AS TXTISIND,TXTITXTART,TXTIPIND,TXTKPOS,TXTKTEXT"
                            + " FROM TXTIND T JOIN TXTKON ON TXTIMANDANT=TXTKMANDANT AND  TXTIPIND=TXTKPIND"
                            + " WHERE TXTIMANDANT=:TXTIMANDANT"
                           + " AND TXTISIND LIKE '" + key + "%' AND TXTITXTART=:TXTITXTART"
                            + " ORDER BY 1,2,3,4";
                        or1.Parameters.Add("TXTIMANDANT", OracleType.NVarChar).Value = dwInput["TXTIMANDANT"];
                        or1.Parameters.Add("TXTITXTART", OracleType.NVarChar).Value = dwInput["TXTITXTART"];
                        break;
                    case 3:
                        or1.CommandText = "SELECT DISTINCT TRIM(TXTISIND) AS TXTISIND,TXTITXTART,TXTIPIND,TXTKPOS,TXTKTEXT FROM TXTIND T JOIN VKPOS "
                        + " P ON T.TXTIMANDANT=VKPMANDANT AND T.TXTITXTART='VAD' AND SUBSTR(T.TXTISIND,1,29)=VKPKOLL||VKPART"
                        + " AND TXTISPRACHKZ='  ' JOIN TXTKON K ON TXTIMANDANT=TXTKMANDANT AND  TXTIPIND=TXTKPIND"
                        + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ' AND P.VKPAUFKRS=:VKPAUFKRS AND P.VKPAUFLFD=:VKPAUFLFD  "
                        + " ORDER BY 1,2,3,4";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwInput["VKPMANDANT"];
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwInput["VKPAUFKRS"];
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwInput["VKPAUFLFD"];
                        break;
                    default:
                        break;
                }
                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    tbLocal = SResult.Tables[0];
                    tbLocal.TableName = "TXTKON";
                }
                SReturn.Merge(SResult);

            }
            catch (Exception ex)
            {
            }

            return SReturn;
        }
        #endregion
        #region======W==============

        public DataSet QueryWAPROF(DataRow dwData, int option = 1)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT *FROM WAPROF WHERE   "
                    + "  WAPMANDANT=:WAPMANDANT AND WAPWAKZ=:WAPWAKZ AND WAPART=:WAPART  AND WAPVAR=:WAPVAR";
                    or1.Parameters.Add("WAPMANDANT", OracleType.NVarChar).Value = dwData["WAPMANDANT"].ToString();
                    or1.Parameters.Add("WAPWAKZ", OracleType.NVarChar).Value = dwData["WAPWAKZ"].ToString();
                    or1.Parameters.Add("WAPART", OracleType.NVarChar).Value = dwData["WAPART"].ToString();
                    or1.Parameters.Add("WAPVAR", OracleType.NVarChar).Value = dwData["WAPVAR"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT *FROM WAPROF WHERE   "
                    + "  WAPMANDANT=:WAPMANDANT AND WAPWAKZ=:WAPWAKZ AND WAPART=:WAPART  AND WAPVAR=:WAPVAR AND WAPANFART=:WAPANFART";
                    or1.Parameters.Add("WAPMANDANT", OracleType.NVarChar).Value = dwData["WAPMANDANT"].ToString();
                    or1.Parameters.Add("WAPWAKZ", OracleType.NVarChar).Value = dwData["WAPWAKZ"].ToString();
                    or1.Parameters.Add("WAPART", OracleType.NVarChar).Value = dwData["WAPART"].ToString();
                    or1.Parameters.Add("WAPVAR", OracleType.NVarChar).Value = dwData["WAPVAR"].ToString();
                    or1.Parameters.Add("WAPANFART", OracleType.NVarChar).Value = dwData["WAPANFART"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT LF.*,M.QPMKURZB FROM EKPOS FL JOIN WAPROF LF ON FL.EKPMANDANT=WAPMANDANT AND WAPWAKZ='F' "
                        + " AND utl_raw.cast_to_varchar2(EKPART)= LF.WAPART LEFT JOIN QPMERKM M ON M.QPMMERKM=LF.WAPANFART"
                        + " WHERE EKPSA<>'AJ' AND EKPMANDANT=:EKPMANDANT AND EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD";
                    or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKKMANDANT"].ToString();
                    or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKKAUFKRS"].ToString();
                    or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKKAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WAPROF";
            }
            set4Return.Merge(Result);
            return set4Return;
        }
        public DataSet QueryWASTPASS(DataRow dwData)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT *FROM WASTPASS WHERE   "
            + "  WSPMANDANT=:WSPMANDANT AND WSPART=:WSPART AND WSPVAR=:WSPVAR";
            or1.Parameters.Add("WSPMANDANT", OracleType.NVarChar).Value = dwData["WSPMANDANT"].ToString();
            or1.Parameters.Add("WSPART", OracleType.NVarChar).Value = dwData["WSPART"].ToString();
            or1.Parameters.Add("WSPVAR", OracleType.NVarChar).Value = dwData["WSPVAR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WASTPASS";
            }
            set4Return.Merge(Result);
            return set4Return;
        }
        public DataSet QueryWASTKE(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WASTKE"
                   + " WHERE WAKMANDANT=:WAKMANDANT AND WAKART=:WAKART AND WAKVAR=:WAKVAR AND WAKWCOL=:WAKWCOL";
                    or1.Parameters.Add("WAKMANDANT", OracleType.NVarChar).Value = dwData["WAKMANDANT"].ToString();
                    or1.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwData["WAKART"].ToString();
                    or1.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwData["WAKVAR"].ToString();
                    or1.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwData["WAKWCOL"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT DISTINCT K.* FROM WDECK  WD "
                        + " JOIN WASTAMM W ON WDART=W.WAART AND WDVAR=W.WAVAR"
                        + " JOIN WASTKE K ON WAART=WAKART AND WAVAR=WAKVAR AND WAKWCOL=WDFARBE"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WASTKE";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryWASTGA(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WASTGA WHERE  "
                        + "  WAGMANDANT=:WAGMANDANT AND WAGART=:WAGART AND WAGVAR=:WAGVAR AND WAGWCOL=:WAGWCOL AND WAGPOS=:WAGPOS AND WAGFOLGEPOS=:WAGFOLGEPOS";
                    or1.Parameters.Add("WAGMANDANT", OracleType.NVarChar).Value = dwData["WAGMANDANT"].ToString();
                    or1.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwData["WAGART"].ToString();
                    or1.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwData["WAGVAR"].ToString();
                    or1.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwData["WAGWCOL"].ToString(); ;
                    or1.Parameters.Add("WAGPOS", OracleType.NVarChar).Value = dwData["WAGPOS"].ToString(); ;
                    or1.Parameters.Add("WAGFOLGEPOS", OracleType.Number).Value = dwData["WAGFOLGEPOS"].ToString();
                    break;
                case 2:
                    break;
                case 4:
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "SELECT DISTINCT   WF.* FROM WDECK WD RIGHT JOIN WASTGA WF ON"
                        + "  WAGMANDANT=WDMANDANT AND WAGART=WDART AND WAGVAR=WDVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    or1.CommandText = "SELECT * FROM WASTGA WHERE  "
                        + "  WAGMANDANT=:WAGMANDANT AND WAGART=:WAGART AND WAGVAR=:WAGVAR";
                    or1.Parameters.Add("WAGMANDANT", OracleType.NVarChar).Value = dwData["WAGMANDANT"].ToString();
                    or1.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwData["WAGART"].ToString();
                    or1.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwData["WAGVAR"].ToString();
                    break;
            }


            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WASTGA";
            }

            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryWTSCHUSS(DataRow dwData)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WTSCHUSS WHERE WTSMANDANT=:WTSMANDANT AND WTSSFLGNR=:WTSSFLGNR";
                or1.Parameters.Add("WTSMANDANT", OracleType.NVarChar).Value = dwData["WTSMANDANT"].ToString();
                or1.Parameters.Add("WTSSFLGNR", OracleType.NVarChar).Value = dwData["WTSSFLGNR"].ToString();
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "WTSCHUSS";
                }
                setReturn.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryWTSTR(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WTSTR WHERE  "
                    + "  WTIMANDANT=:WTIMANDANT AND WTIART=:WTIART AND WTIVAR=:WTIVAR";
                    or1.Parameters.Add("WTIMANDANT", OracleType.NVarChar).Value = dwData["WTIMANDANT"].ToString();
                    or1.Parameters.Add("WTIART", OracleType.NVarChar).Value = dwData["WTIART"].ToString();
                    or1.Parameters.Add("WTIVAR", OracleType.NVarChar).Value = dwData["WTIVAR"].ToString();
                    break;
                case 2:
                default:
                    or1.CommandText = "SELECT * FROM WTSTR WHERE  "
                + "  WTIMANDANT=:WTIMANDANT AND WTIART=:WTIART AND WTIVAR=:WTIVAR";
                    or1.Parameters.Add("WTIMANDANT", OracleType.NVarChar).Value = dwData["WTIMANDANT"].ToString();
                    or1.Parameters.Add("WTIART", OracleType.NVarChar).Value = dwData["WTIART"].ToString();
                    or1.Parameters.Add("WTIVAR", OracleType.NVarChar).Value = dwData["WTIVAR"].ToString();
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WTSTR";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryWAFARBEN(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = null;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WAFARBEN WHERE   "
                    + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART AND WAFVAR=:WAFVAR AND WAFZUART=:WAFZUART AND WAFZUSATZ=:WAFZUSATZ ";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwData["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwData["WAFART"].ToString();
                    or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwData["WAFVAR"].ToString();
                    or1.Parameters.Add("WAFZUART", OracleType.NVarChar).Value = dwData["WAFZUART"].ToString();
                    or1.Parameters.Add("WAFZUSATZ", OracleType.NVarChar).Value = dwData["WAFZUSATZ"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WAFARBEN WHERE   "
                    + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART AND WAFVAR=:WAFVAR ";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwData["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwData["WAFART"].ToString();
                    or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwData["WAFVAR"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT WAFART,WAFVAR,WAFZUSATZ,WAFZUABAK FROM WAFARBEN WHERE   "
                    + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART AND WAFVAR=:WAFVAR ";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwData["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwData["WAFART"].ToString();
                    or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwData["WAFVAR"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT WF.* FROM WDECK WD RIGHT JOIN WAFARBEN WF ON"
                        + "  WAFMANDANT=WDMANDANT AND WAFART=WDART AND WAFVAR=WDVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM WAFARBEN WHERE   "
                    + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART  ";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwData["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwData["WAFART"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT DISTINCT  W.* FROM WDECK  WD "
                        + " JOIN WAFARBEN W ON WDART=W.WAFART AND WDVAR=W.WAFVAR AND WDFARBE=WAFZUSATZ AND WAFZUART=:WAFZUART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WAFZUART", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT  DISTINCT W.* FROM WDECK  WD "
                        + " JOIN WAFARBEN W ON WDART=W.WAFART AND WDVAR=W.WAFVAR AND WDBESCHICH=WAFZUSATZ AND WAFZUART=:WAFZUART"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WAFZUART", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 51:
                    or1.CommandText = "SELECT WAFZUSATZ AS FSFFARBE FROM WAFARBEN WHERE   "
                    + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART  ";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwData["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwData["WAFART"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);

            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WAFARBEN";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryWASTAMM(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                        + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                        or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                        or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                        or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                            + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                        or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                        or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                        or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwData["WAVAR"].ToString();
                        break;

                    case 3:
                        or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                        + "  WAMANDANT=:WAMANDANT AND WAART=:WAART";
                        or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                        or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                        break;
                    case 31:
                        or1.CommandText = "SELECT WAART AS FSART FROM WASTAMM WHERE  "
                            + "  WAMANDANT=:WAMANDANT AND WAART=:WAART";
                        or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwData["WAMANDANT"].ToString();
                        or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwData["WAART"].ToString();
                        break;
                    case 4:
                        or1.CommandText = " SELECT DISTINCT WF.* FROM WDECK WD RIGHT JOIN WASTAMM WF ON"
                            + " WAMANDANT=WDMANDANT AND WAART=WDART AND WAVAR=WDVAR "
                            + " WHERE WAKUNDNR='        ' AND WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                        or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                        or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                        or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                        break;
                    case 5:
                        or1.CommandText = "SELECT DISTINCT WD.WDAUFKRS,WDAUFLFD,WDAUFPOS,WDSA,WDUPOS,W.* FROM WDECK  WD "
                            + " JOIN WASTAMM W ON WDART=W.WAART AND WDVAR=W.WAVAR "
                            + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                        or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                        or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                        or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                        break;
                    default:
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "WASTAMM";
                }
                setReturn.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet QueryWBBST(DataRow dwData)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM WBBST "
                + " WHERE WBBMANDANT=:WBBMANDANT and WBBRWKRS=:WBBRWKRS AND WBBRWLFD=:WBBRWLFD AND WBBPOS=:WBBPOS";
            or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
            or1.Parameters.Add("WBBRWKRS", OracleType.NVarChar).Value = dwData["WBBRWKRS"].ToString();
            or1.Parameters.Add("WBBRWLFD", OracleType.NVarChar).Value = dwData["WBBRWLFD"].ToString();
            or1.Parameters.Add("WBBPOS", OracleType.NVarChar).Value = dwData["WBBPOS"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WBBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryWBBST(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            string qty = "0";
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    qty = dwData["WBBISTKLG"].ToString();
                    or1.CommandText = "SELECT * FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
              + " AND WBBDISPOART=:WBBDISPOART "
              + " AND WBBDISPOVAR=:WBBDISPOVAR "
              + " AND WBBWAKZ=:WBBWAKZ "
              + " AND WBBLO=:WBBLO "
                        //              + " AND WBBLB=:WBBLB "
              + " AND WBBDESS=:WBBDESS "
              + " AND WBBCOLORIT=:WBBCOLORIT "
              + " AND WBBBESCHICH=:WBBBESCHICH "
              + " AND WBBFARBE=:WBBFARBE "
              + " AND WBBAUFLFD='000000'"
              + " AND WBBISTKLG-WBBTSTKLG>=" + qty
              + " ORDER BY WBBSSTKLG ASC";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBDISPOART", OracleType.NVarChar).Value = dwData["WBBDISPOART"].ToString();
                    or1.Parameters.Add("WBBDISPOVAR", OracleType.NVarChar).Value = dwData["WBBDISPOVAR"].ToString();
                    or1.Parameters.Add("WBBWAKZ", OracleType.NVarChar).Value = dwData["WBBWAKZ"].ToString();
                    or1.Parameters.Add("WBBLO", OracleType.NVarChar).Value = dwData["WBBLO"].ToString();
                    //or1.Parameters.Add("WBBLB", OracleType.NVarChar).Value = dwData["WBBLB"].ToString();
                    or1.Parameters.Add("WBBDESS", OracleType.NVarChar).Value = dwData["WBBDESS"].ToString();
                    or1.Parameters.Add("WBBCOLORIT", OracleType.NVarChar).Value = dwData["WBBCOLORIT"].ToString();
                    or1.Parameters.Add("WBBBESCHICH", OracleType.NVarChar).Value = dwData["WBBBESCHICH"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
                        + " AND WBBDISPOART=:WBBDISPOART "
                        + " AND WBBDISPOVAR=:WBBDISPOVAR "
                        + " AND WBBWAKZ=:WBBWAKZ "
                        + " AND WBBLO=:WBBLO "
                        + " AND WBBVERSANDKZ='N' "
                        + " AND WBBERLKZ <> 'J' "
                        + " AND WBBISTKLG > 0 "
                        // + " AND WBBLB=:WBBLB "                        
                        + " AND WBBDESS=:WBBDESS "
                        + " AND WBBCOLORIT=:WBBCOLORIT "
                        + " AND WBBBESCHICH=:WBBBESCHICH "
                        + " AND WBBFARBE=:WBBFARBE "
                        + " AND WBBAUFLFD='000000'"
                        + " ORDER BY WBBSSTKLG ASC";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBDISPOART", OracleType.NVarChar).Value = dwData["WBBDISPOART"].ToString();
                    or1.Parameters.Add("WBBDISPOVAR", OracleType.NVarChar).Value = dwData["WBBDISPOVAR"].ToString();
                    or1.Parameters.Add("WBBWAKZ", OracleType.NVarChar).Value = dwData["WBBWAKZ"].ToString();
                    or1.Parameters.Add("WBBLO", OracleType.NVarChar).Value = dwData["WBBLO"].ToString();
                    //or1.Parameters.Add("WBBLB", OracleType.NVarChar).Value = dwData["WBBLB"].ToString();
                    or1.Parameters.Add("WBBDESS", OracleType.NVarChar).Value = dwData["WBBDESS"].ToString();
                    or1.Parameters.Add("WBBCOLORIT", OracleType.NVarChar).Value = dwData["WBBCOLORIT"].ToString();
                    or1.Parameters.Add("WBBBESCHICH", OracleType.NVarChar).Value = dwData["WBBBESCHICH"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    break;
                case 3:
                    //WBBAUFTYP	WBBAUFKRS	WBBAUFLFD	WBBAUFPOS
                    or1.CommandText = "SELECT  WBBRWLFD,WBBPOS,WBBAUFKRS,WBBAUFLFD,WBBAUFPOS,WBBANZTEILE,WBBTP,WBBSTKNR,WBBISTKLG,WBBIGEW,WBBPACKTYP,WBBAUFMSL,WBBTAX,WBBDPART"
                    + " FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
                    + " AND WBBAUFTYP=:WBBAUFTYP "
                    + " AND WBBAUFKRS=:WBBAUFKRS "
                    + " AND WBBAUFLFD=:WBBAUFLFD "
                    + " AND WBBALIEFSCH='00000000'"
                    + " ORDER BY WBBRWLFD,WBBPOS";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBAUFTYP", OracleType.NVarChar).Value = dwData["WBBAUFTYP"].ToString();
                    or1.Parameters.Add("WBBAUFKRS", OracleType.NVarChar).Value = dwData["WBBAUFKRS"].ToString();
                    or1.Parameters.Add("WBBAUFLFD", OracleType.NVarChar).Value = dwData["WBBAUFLFD"].ToString();
                    break;
                case 4:
                    //WBBAUFTYP	WBBAUFKRS	WBBAUFLFD	WBBAUFPOS
                    or1.CommandText = "SELECT  WBBRWLFD,WBBPOS,WBBAUFKRS,WBBAUFLFD,WBBAUFPOS,WBBANZTEILE,WBBSTKNR,WBBISTKLG,WBBIGEW,WBBPACKTYP,WBBAUFMSL,WBBALIEFSCH"
                    + " FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
                    + " AND WBBALIEFSCH=:WBBALIEFSCH "
                    + " ORDER BY WBBRWLFD,WBBPOS";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBALIEFSCH", OracleType.NVarChar).Value = dwData["WBBALIEFSCH"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
              + " AND WBBDISPOART=:WBBDISPOART "
              + " AND WBBDISPOVAR=:WBBDISPOVAR "
              + " AND WBBWAKZ=:WBBWAKZ "
              + " AND WBBLO=:WBBLO "
                        //              + " AND WBBLB=:WBBLB "
              + " AND WBBDESS=:WBBDESS "
              + " AND WBBCOLORIT=:WBBCOLORIT "
              + " AND WBBBESCHICH=:WBBBESCHICH "
              + " AND WBBFARBE=:WBBFARBE "
              + " AND WBBAUFLFD='000000'"
              + " AND WBBISTKLG-WBBTSTKLG>=0"
              + " ORDER BY WBBSSTKLG ASC";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBDISPOART", OracleType.NVarChar).Value = dwData["WBBDISPOART"].ToString();
                    or1.Parameters.Add("WBBDISPOVAR", OracleType.NVarChar).Value = dwData["WBBDISPOVAR"].ToString();
                    or1.Parameters.Add("WBBWAKZ", OracleType.NVarChar).Value = dwData["WBBWAKZ"].ToString();
                    or1.Parameters.Add("WBBLO", OracleType.NVarChar).Value = dwData["WBBLO"].ToString();
                    //or1.Parameters.Add("WBBLB", OracleType.NVarChar).Value = dwData["WBBLB"].ToString();
                    or1.Parameters.Add("WBBDESS", OracleType.NVarChar).Value = dwData["WBBDESS"].ToString();
                    or1.Parameters.Add("WBBCOLORIT", OracleType.NVarChar).Value = dwData["WBBCOLORIT"].ToString();
                    or1.Parameters.Add("WBBBESCHICH", OracleType.NVarChar).Value = dwData["WBBBESCHICH"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT * FROM WBBST WHERE WBBMANDANT=:WBBMANDANT "
                        + " AND WBBWAKZ=:WBBWAKZ "
                        + " AND WBBART=:WBBART "
                        + " AND WBBLO=:WBBLO "
                        + " AND WBBLB=:WBBLB "
                        + " AND WBBFARBE=:WBBFARBE "
                        + " AND WBBAUFLFD='000000'"
                        + " AND WBBISTKLG-WBBTSTKLG>=0"
                        + " ORDER BY WBBSTKNR ASC";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBWAKZ", OracleType.NVarChar).Value = dwData["WBBWAKZ"].ToString();
                    or1.Parameters.Add("WBBART", OracleType.NVarChar).Value = dwData["WBBART"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    or1.Parameters.Add("WBBLO", OracleType.NVarChar).Value = dwData["WBBLO"].ToString();
                    or1.Parameters.Add("WBBLB", OracleType.NVarChar).Value = dwData["WBBLB"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WBBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryICC_WBBST(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            string qty = "0";
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    break;
                case 2:
                    /*
                    or1.CommandText = "SELECT SEQ_ICC_MU.NEXTVAL AS BAID,WBBMANDANT AS MANDANT,WBBART AS ART,WBBVAR AS VAR,WBBFARBE AS COLOR,WBBLO AS LO,WBBLB AS LB,"
                    + "WBBISTKLG*0.001 AS QTY,0 AS QTYLOCKED,WBBISTKLG*0.001 AS QTYFREE, WBBSTKNR AS STK FROM WBBST M  "
                            + " WHERE WBBMANDANT=:WBBMANDANT AND WBBART=:WBBART AND WBBVAR=:WBBVAR AND WBBFARBE=:WBBFARBE"
                            + " AND WBBISTKLG>0 AND (WBBLO='01' OR WBBLB='KC') ";*/
                    or1.CommandText = "SELECT 1 AS BAID,A.* FROM (SELECT MAX(WBBMANDANT) AS MANDANT,WBBART AS ART,WBBVAR AS VAR,WBBFARBE AS COLOR,WBBLO AS LO,WBBLB AS LB,"
                    + "SUM(WBBISTKLG*0.001) AS QTY,0 AS QTYLOCKED,SUM(WBBISTKLG*0.001) AS QTYFREE, MAX(WBBSTKNR) AS STK FROM WBBST M  "
                            + " WHERE WBBMANDANT=:WBBMANDANT AND WBBART=:WBBART AND WBBVAR=:WBBVAR AND WBBFARBE=:WBBFARBE"
                            + " AND WBBISTKLG>0 AND (WBBLO='01' OR WBBLB='KC') "
                            + " GROUP BY WBBART,WBBVAR,WBBFARBE,WBBLB,WBBLO) A";
                    or1.Parameters.Add("WBBMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBBART", OracleType.NVarChar).Value = dwData["WBBART"].ToString();
                    or1.Parameters.Add("WBBVAR", OracleType.NVarChar).Value = dwData["WBBVAR"].ToString();
                    or1.Parameters.Add("WBBFARBE", OracleType.NVarChar).Value = dwData["WBBFARBE"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_WBBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryWDECK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            string FSARTPRGR = "";
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WDECK  "
                    + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDART=:WDART  AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT WDMANDANT,WDSA,WDUPOS,WDAUFKRS,WDAUFLFD,WDAUFPOS"
                        + " ,WDWAKZ,WDART,WDFARBE,WDBESCHICH,WDVAR,TO_CHAR(VKPLIEFTERM) AS WDDAT,VKPMENGE1*VKPMEEHFKT*0.001*0.001 AS WDBEDARF"
                        + ",VKPSACHBE,VKPKUNDNR,VKPVB,VKPVG,VKPLAEBIS,VKPLAEVON,VKPAUFMART"
                        + " FROM WDECK JOIN VKPOS ON"
                        + " WDSA='K' AND WDAUFKRS=VKPAUFKRS AND WDAUFLFD=VKPAUFLFD AND WDAUFPOS=VKPAUFPOS AND VKPSA='  '"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwData["WDUPOS"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 7:
                    or1.CommandText = "SELECT DISTINCT ABKMANDANT, ABKAUFKRS,ABKAUFLFD,ABPART,FSABEZ,LSLIEFNA AS EXTPRODUCER,ABPLIEFNR,ABPANRKR,ABPALFDNR  "
                    + " FROM WDECK F JOIN ABKOPF K ON F.WDAUFKRS=K.ABKAUFKRS AND  F.WDAUFLFD=K.ABKAUFLFD"
                    + " JOIN ABPOS P ON F.WDAUFKRS=P.ABPAUFKRS AND  F.WDAUFLFD=P.ABPAUFLFD AND  F.WDAUFPOS=P.ABPAUFPOS AND ABPGESSTA='SP'"
                    + " LEFT JOIN FSSTAMM M ON ABPART=FSART"
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                    + " WHERE F.WDART=:WDART AND F.WDTYP=:WDTYP";
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break;
                case 8:
                    or1.CommandText = "SELECT WD.*, WAUEBM as UM,WAFGRLFD as FGRLFD,0 AS RATIO FROM WDECK WD"
                        + " LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND "
                        + " WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 9://分组 
                    FSARTPRGR = dwData["WDART"].ToString().Trim();
                    or1.CommandText = "SELECT WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M"
                        + "  ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF"
                        + " ORDER BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break; 
                case 91://分组 
                    FSARTPRGR = dwData["WDART"].ToString().Trim();
                    or1.CommandText = "SELECT FSSZUSCHN,WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M"
                        + "  ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M. FSSZUSCHN=:FSSZUSCHN AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,FSSZUSCHN,ABACOLORREF"
                        + " ORDER BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,FSSZUSCHN,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 92://分组 
                    or1.CommandText = "SELECT WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME,FSSZUSCHN,M.ABPART,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS  AND WDAUFLFD=ABPAUFLFD    AND WDAUFPOS=ABPAUFPOS AND  ABPSPGRD<='89' "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M.FSSZUSCHN=:FSSZUSCHN "
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF,FSSZUSCHN,M.ABPART"
                        + " ORDER BY ABPART,FSSZUSCHN,WDART,WDVAR,WDFARBE,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 10:
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,WD.* "
                    + " FROM WDECK WD JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS  "
                        + " WHERE WDMANDANT=:FDMANDANT AND WDART=:FDART";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    break;

                case 11:
                    string SECTION = dwData["WDART"].ToString().Trim();
                    or1.CommandText = " SELECT DISTINCT WDART FROM WDECK LEFT JOIN ABPOS ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS"
                        + " LEFT JOIN FSSTUELI ON ABPART=FSSART AND WDART=FSSMART "
                        + " JOIN FSSTAMM M ON FSART=ABPART "
                        + " WHERE  ABPSPGRD>'89' AND FSSZUSCHN='J' AND M.FSARTPRGR IN (" + SECTION + ")"
                        + " AND WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break;
                case 12:
                    or1.CommandText = "SELECT WD.* FROM WDECK WD "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD "
                        + " AND  WDART=:WDART AND WDVAR=:WDVAR AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwData["WDVAR"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    break;
                case 13:
                    or1.CommandText = "SELECT WD.*, WAUEBM as UM,WAFGRLFD as FGRLFD,0 AS RATIO FROM WDECK WD"
                        + " LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND "
                        + " WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 14:
                    or1.CommandText = "SELECT WD.* FROM WDECK WD "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD "
                        + " AND  WDART=:WDART  ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    break;
                case 15:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 16:
                    or1.CommandText = "SELECT DISTINCT WDART FROM EKPOS EK JOIN WDECK WD ON "
                        + " EKPSA<>'AJ'  AND utl_raw.cast_to_varchar2(EKPART)=WD.WDART  "
                        + " AND utl_raw.cast_to_varchar2(EKPFARBE)=WD.WDFARBE   AND EKPBEKZ=:EKPBEKZ"
                        + " JOIN ABPOS ON ABPAUFKRS=WDAUFKRS AND ABPAUFLFD=WDAUFLFD AND ABPAUFPOS=WDAUFPOS"
                        + " JOIN FSSTAMM M ON FSART=ABPART"
                        + " JOIN FSSTUELI ON ABPART=FSSART AND WDART=FSSMART AND FSSZUSCHN<>'J' AND "
                        + " M.FSARTPRGR IN  (" + dwData["WDART"].ToString().Trim() + ")"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 17:
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,WD.* "
                    + " FROM WDECK WD JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS  "
                        + " WHERE WDMANDANT=:WDMANDANT AND ABPART=:WDART AND WDART=:WDPRART";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwData["WDPRART"].ToString();
                    break;
                case 18:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT  AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 99:
                    or1.CommandText = "SELECT WDMANDANT,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDSA,WDUPOS,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH,WDVAR	"
                    + ", WAUEBM as UM,WAFGRLFD as FGRLFD,WABEZ AS ARTDES,WAFBEZ AS CDES,WDBEDARF,WDZUGET,WDRESERV,0 AS RATIO"
                        + "  FROM WDECK  WD LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " LEFT JOIN WAFARBEN ON WAFART=WDART AND WAFVAR=WDVAR AND WAFZUSATZ=WDFARBE "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD"
                        + " ORDER BY WDMANDANT,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WDECK";
            Return = Result;
            return Return;
        }

        public DataSet QueryWBDAT(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WBDAT WHERE WBMANDANT=:WBMANDANT "
                    + "AND WBRWKRS=:WBRWKRS AND WBRWLFD=:WBRWLFD ";
                    or1.Parameters.Add("WBMANDANT", OracleType.NVarChar).Value = dwData["WBMANDANT"].ToString();
                    or1.Parameters.Add("WBRWKRS", OracleType.NVarChar).Value = dwData["WBRWKRS"].ToString();
                    or1.Parameters.Add("WBRWLFD", OracleType.NVarChar).Value = dwData["WBRWLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WBDAT";
            Return = Result;
            return Return;
        }
        public DataSet QueryWBBEW(DataRow dwData)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM WBBEW WHERE WBEWMANDANT=:WBEWMANDANT AND WBEWBELEG=:WBEWBELEG AND WBEWLFDNR=:WBEWLFDNR ";
            or1.Parameters.Add("WBEWMANDANT", OracleType.NVarChar).Value = dwData["WBEWMANDANT"].ToString();
            or1.Parameters.Add("WBEWBELEG", OracleType.NVarChar).Value = dwData["WBEWBELEG"].ToString();
            or1.Parameters.Add("WBEWLFDNR", OracleType.NVarChar).Value = dwData["WBEWLFDNR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WBBEW";
            Return = Result;
            return Return;
        }
        /// <summary>
        /// option==1, 获取最大的WBEWBELEG
        /// </summary>
        /// <param name="dwData"></param>
        /// <param name="option"></param>
        /// <returns></returns>
        public DataSet QueryWBBEW(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT MAX(WBEWBELEG) AS WBEWBELEG FROM WBBEW ";
                    break;
                case 2:
                    or1.CommandText = "SELECT WBEWSTKNR,Sum(WBEWMTR) AS TBCM from wbbew  "
                    + " where  WBEWMANDANT=:WBEWMANDANT AND WBEWSTKNR = :WBEWSTKNR and WBEWBS=64 group by WBEWSTKNR ";
                    or1.Parameters.Add("WBEWMANDANT", OracleType.NVarChar).Value = dwData["WBBMANDANT"].ToString();
                    or1.Parameters.Add("WBEWSTKNR", OracleType.NVarChar).Value = dwData["WBBSTKNR"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT*FROM WBBEW WHERE (WBEWBS='13'OR WBEWBS='48' OR WBEWBS='36')"
                    + " AND WBEWMANDANT=:WBEWMANDANT AND WBEWAUFKRS=:WBEWAUFKRS  AND WBEWAUFLFD=:WBEWAUFLFD ";
                    or1.Parameters.Add("WBEWMANDANT", OracleType.NVarChar).Value = dwData["WBEWMANDANT"].ToString();
                    or1.Parameters.Add("WBEWAUFKRS", OracleType.NVarChar).Value = dwData["WBEWAUFKRS"].ToString();
                    or1.Parameters.Add("WBEWAUFLFD", OracleType.NVarChar).Value = dwData["WBEWAUFLFD"].ToString();
                    break;
                case 99:
                    or1.CommandText = " SELECT WBEWAUFKRS,WBEWAUFLFD,WBEWAUFPOS,WBEWART,WBEWVAR,WBEWFARBE,WBEWBESCHICH,WBEWBS,SUM(WBEWMTR*0.001) AS WBEWMTR "
                     + " FROM WBBEW "
                     + "  WHERE WBEWAUFTYP='V' AND WBEWBS=36 AND WBEWMANDANT=:WBEWMANDANT AND WBEWAUFKRS=:WBEWAUFKRS AND WBEWAUFLFD=:WBEWAUFLFD "
                     + " GROUP BY  WBEWAUFKRS,WBEWAUFLFD,WBEWAUFPOS,WBEWART,WBEWVAR,WBEWFARBE,WBEWBESCHICH,WBEWBS ";
                    or1.Parameters.Add("WBEWMANDANT", OracleType.NVarChar).Value = dwData["WBEWMANDANT"].ToString();
                    or1.Parameters.Add("WBEWAUFKRS", OracleType.NVarChar).Value = dwData["WBEWAUFKRS"].ToString();
                    or1.Parameters.Add("WBEWAUFLFD", OracleType.NVarChar).Value = dwData["WBEWAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WBBEW";
            Return = Result;
            return Return;
        }

        public DataSet QueryWGBST(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM WGBST WHERE "
                  + "  WGMANDANT=:WGMANDANT AND WGWAKZ=:WGWAKZ AND WGART=:WGART AND WGVAR=:WGVAR"
                  + "  AND WGFARBE=:WGFARBE AND WGBESCHICH=:WGBESCHICH AND WGDESS=:WGDESS AND WGCOLORIT=:WGCOLORIT"
                  + "   AND WGLO=:WGLO"
                  + " ORDER BY WGMJJ DESC,WGMM DESC ";
                    or1.Parameters.Add("WGMANDANT", OracleType.NVarChar).Value = dwData["WGMANDANT"].ToString();
                    or1.Parameters.Add("WGWAKZ", OracleType.NVarChar).Value = dwData["WGWAKZ"].ToString();
                    or1.Parameters.Add("WGART", OracleType.NVarChar).Value = dwData["WGART"].ToString();
                    or1.Parameters.Add("WGVAR", OracleType.NVarChar).Value = dwData["WGVAR"].ToString();
                    or1.Parameters.Add("WGFARBE", OracleType.NVarChar).Value = dwData["WGFARBE"].ToString();
                    or1.Parameters.Add("WGBESCHICH", OracleType.NVarChar).Value = dwData["WGBESCHICH"].ToString();
                    or1.Parameters.Add("WGDESS", OracleType.NVarChar).Value = dwData["WGDESS"].ToString();
                    or1.Parameters.Add("WGCOLORIT", OracleType.NVarChar).Value = dwData["WGCOLORIT"].ToString();
                    or1.Parameters.Add("WGLO", OracleType.NVarChar).Value = dwData["WGLO"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WGBST WHERE "
                  + "  WGMANDANT=:WGMANDANT AND WGSA=:WGSA AND WGKUNDNR=:WGKUNDNR AND WGWERK=:WGWERK AND WGABT=:WGABT AND WGWAKZ=:WGWAKZ AND WGART=:WGART AND WGVAR=:WGVAR"
                  + "  AND WGFARBE=:WGFARBE AND WGBESCHICH=:WGBESCHICH AND WGDESS=:WGDESS AND WGCOLORIT=:WGCOLORIT"
                  + "  AND WGZUSTAND=:WGZUSTAND AND WGZENSUR=:WGZENSUR AND WGZENSURKZ=:WGZENSURKZ AND WGLO=:WGLO AND WGMJJ=:WGMJJ AND WGMM=:WGMM"
                  + " ORDER BY WGMJJ DESC,WGMM DESC ";
                    or1.Parameters.Add("WGMANDANT", OracleType.NVarChar).Value = dwData["WGMANDANT"].ToString();
                    or1.Parameters.Add("WGSA", OracleType.NVarChar).Value = dwData["WGSA"].ToString();
                    or1.Parameters.Add("WGKUNDNR", OracleType.NVarChar).Value = dwData["WGKUNDNR"].ToString();
                    or1.Parameters.Add("WGWERK", OracleType.NVarChar).Value = dwData["WGWERK"].ToString();
                    or1.Parameters.Add("WGABT", OracleType.NVarChar).Value = dwData["WGABT"].ToString();
                    or1.Parameters.Add("WGWAKZ", OracleType.NVarChar).Value = dwData["WGWAKZ"].ToString();
                    or1.Parameters.Add("WGART", OracleType.NVarChar).Value = dwData["WGART"].ToString();
                    or1.Parameters.Add("WGDESS", OracleType.NVarChar).Value = dwData["WGDESS"].ToString();
                    or1.Parameters.Add("WGCOLORIT", OracleType.NVarChar).Value = dwData["WGCOLORIT"].ToString();
                    or1.Parameters.Add("WGFARBE", OracleType.NVarChar).Value = dwData["WGFARBE"].ToString();
                    or1.Parameters.Add("WGBESCHICH", OracleType.NVarChar).Value = dwData["WGBESCHICH"].ToString();
                    or1.Parameters.Add("WGVAR", OracleType.NVarChar).Value = dwData["WGVAR"].ToString();
                    or1.Parameters.Add("WGZUSTAND", OracleType.NVarChar).Value = dwData["WGZUSTAND"].ToString();
                    or1.Parameters.Add("WGZENSUR", OracleType.NVarChar).Value = dwData["WGZENSUR"].ToString();
                    or1.Parameters.Add("WGZENSURKZ", OracleType.NVarChar).Value = dwData["WGZENSURKZ"].ToString();
                    or1.Parameters.Add("WGLO", OracleType.NVarChar).Value = dwData["WGLO"].ToString();
                    or1.Parameters.Add("WGMJJ", OracleType.NVarChar).Value = dwData["WGMJJ"].ToString();
                    or1.Parameters.Add("WGMM", OracleType.NVarChar).Value = dwData["WGMM"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM WGBST WHERE "
                  + "  WGMANDANT=:WGMANDANT   AND WGWAKZ=:WGWAKZ AND WGART=:WGART AND WGVAR=:WGVAR"
                  + "  AND WGFARBE=:WGFARBE  AND WGLO=:WGLO AND WGMJJ=:WGMJJ AND WGMM=:WGMM"
           ;
                    or1.Parameters.Add("WGMANDANT", OracleType.NVarChar).Value = dwData["WGMANDANT"].ToString();
                    or1.Parameters.Add("WGWAKZ", OracleType.NVarChar).Value = dwData["WGWAKZ"].ToString();
                    or1.Parameters.Add("WGART", OracleType.NVarChar).Value = dwData["WGART"].ToString();
                    or1.Parameters.Add("WGFARBE", OracleType.NVarChar).Value = dwData["WGFARBE"].ToString();
                    or1.Parameters.Add("WGVAR", OracleType.NVarChar).Value = dwData["WGVAR"].ToString();
                    or1.Parameters.Add("WGLO", OracleType.NVarChar).Value = dwData["WGLO"].ToString();
                    or1.Parameters.Add("WGMJJ", OracleType.NVarChar).Value = dwData["WGMJJ"].ToString();
                    or1.Parameters.Add("WGMM", OracleType.NVarChar).Value = dwData["WGMM"].ToString();
                    break;
            }


            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WGBST";
            Return = Result;
            return Return;
        }
        public DataSet QueryWTEINZ(DataRow dwData)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT *FROM  WTEINZ "
                + "  WHERE WTEMANDANT=:WTEMANDANT AND WTEEINZNR=:WTEEINZNR";
            or1.Parameters.Add("WTEMANDANT", OracleType.NVarChar).Value = dwData["WTEMANDANT"].ToString();
            or1.Parameters.Add("WTEEINZNR", OracleType.NVarChar).Value = dwData["WTEEINZNR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WTEINZ";
            }
            set4Return.Merge(Result);
            return set4Return;
        }
        public DataSet QueryWTPASS(DataRow dwData)
        {
            DataSet set4Return = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT *FROM WTPASS WHERE   "
            + "  WTPMANDANT=:WTPMANDANT AND WTPPASSNR=:WTPPASSNR";
            or1.Parameters.Add("WTPMANDANT", OracleType.NVarChar).Value = dwData["WTPMANDANT"].ToString();
            or1.Parameters.Add("WTPPASSNR", OracleType.NVarChar).Value = dwData["WTPPASSNR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WTPASS";
            }
            set4Return.Merge(Result);
            return set4Return;
        }
        public DataSet QueryWTGEW(DataRow dwData)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            //select * from WTGEW where WTGART='PV912102            ' AND WTGVAR='12'

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM WTGEW WHERE   "
            + "  WTGMANDANT=:WTGMANDANT AND WTGART=:WTGART AND WTGVAR=:WTGVAR";
            or1.Parameters.Add("WTGMANDANT", OracleType.NVarChar).Value = dwData["WTGMANDANT"].ToString();
            or1.Parameters.Add("WTGART", OracleType.NVarChar).Value = dwData["WTGART"].ToString();
            or1.Parameters.Add("WTGVAR", OracleType.NVarChar).Value = dwData["WTGVAR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WTGEW";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public DataSet QueryWTSAER(DataRow dwData)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1;
            //select * from WTGEW where WTGART='PV912102            ' AND WTGVAR='12'

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM WTSAER WHERE   "
            + "  WTBMANDANT=:WTBMANDANT AND WTBSRFNR=:WTBSRFNR";
            or1.Parameters.Add("WTBMANDANT", OracleType.NVarChar).Value = dwData["WTBMANDANT"].ToString();
            or1.Parameters.Add("WTBSRFNR", OracleType.NVarChar).Value = dwData["WTBSRFNR"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "WTSAER";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        #endregion
        #region======V==============
        public DataSet QueryVAART(DataRow dwData)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = " SELECT * FROM VAART WHERE ROWNUM<2 AND VAAMANDANT=:VAAMANDANT"
                + "  AND VAAKOLL=:VAAKOLL AND VAAART =:VAAART"
            ;
            or1.Parameters.Add("VAAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
            or1.Parameters.Add("VAAKOLL", OracleType.NVarChar).Value = dwData["VAAKOLL"].ToString();
            or1.Parameters.Add("VAAART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAART";
            Return = Result;
            return Return;
        }
        public DataSet QueryVAART(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:

                    or1.CommandText = " SELECT VAAMANDANT,VAAKOLL,VAAART,VAABEZ,VAAARTST" +
                        " FROM VAART WHERE VAAMANDANT=:VAAMANDANT AND VAAART =:VAAART";
                    or1.Parameters.Add("VAAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("VAAART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM VAART WHERE VAAMANDANT=:VAAMANDANT"
                    + "  AND VAAART =:VAAART";
                    or1.Parameters.Add("VAAMANDANT", OracleType.NVarChar).Value = dwData["VAAMANDANT"].ToString();
                    or1.Parameters.Add("VAAART", OracleType.NVarChar).Value = dwData["VAAART"].ToString();
                    break;
                case 3:
                    or1.CommandText = "  SELECT A.* FROM VAART A JOIN VKPOS V ON A.VAAMANDANT=V.VKPMANDANT"
                        + " AND A.VAAKOLL=V.VKPKOLL AND A.VAAART=V.VKPART"
                        + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD ";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                    or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                    or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAART";
            Return = Result;
            return Return;
        }
        public DataSet QueryVAKDBEZ(DataRow dwData, int option)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 3:
                    or1.CommandText = "  SELECT A.* FROM VAKDBEZ  A "
                    + " JOIN VKPOS ON VKPKOLL=VAKBKOLL AND VKPART=VAKBART AND VKPFARBE=VAKBFARBE AND VKPKUNDNR=VAKBKUNDNR"
                        + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD ";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                    or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                    or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAKDBEZ";
            Return = Result;
            return Return;
        }

        public DataSet QueryVAFARBEN(DataRow dwData)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM VAFARBEN  WHERE VAFMANDANT=:VAFMANDANT"
            + " AND VAFKOLL=:VAFKOLL AND VAFART =:VAFART AND VAFFARBE=:VAFFARBE"
            ;
            or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwData["VAFMANDANT"].ToString();
            or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwData["VAFKOLL"].ToString();
            or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwData["VAFART"].ToString();
            or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = dwData["VAFFARBE"].ToString();
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAFARBEN";
            Return = Result;
            return Return;
        }
        public DataSet QueryVAFARBEN(string client, string coll, string art, string color)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM VAFARBEN  WHERE VAFMANDANT=:VAFMANDANT"
            + " AND VAFKOLL=:VAFKOLL AND VAFART =:VAFART AND VAFFARBE=:VAFFARBE"
            ;
            or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = coll;
            or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = art;
            or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = color;
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAFARBEN";
            Return = Result;
            return Return;
        }
        public DataSet QueryVAFARBEN(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM VAFARBEN  WHERE  VAFMANDANT=:VAFMANDANT"
                        + " AND VAFKOLL=:VAFKOLL AND VAFART =:VAFART";
                    or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwData["VAFMANDANT"].ToString();
                    or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwData["VAFKOLL"].ToString();
                    or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwData["VAFART"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM VAFARBEN  WHERE  VAFMANDANT=:VAFMANDANT"
                        + " AND VAFKOLL=:VAFKOLL AND VAFART =:VAFART AND VAFFARBE=:VAFFARBE";
                    or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwData["VAFMANDANT"].ToString();
                    or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwData["VAFKOLL"].ToString();
                    or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwData["VAFART"].ToString();
                    or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = dwData["VAFFARBE"].ToString();
                    break;
                case 3:
                    or1.CommandText = " SELECT A.* FROM VAFARBEN A JOIN VKPOS V ON A.VAFMANDANT=V.VKPMANDANT"
                        + " AND A.VAFKOLL=V.VKPKOLL AND A.VAFART=V.VKPART AND A.VAFFARBE=V.VKPFARBE"
                        + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD ";
                    or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                    or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                    or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT * FROM VAFARBEN  WHERE  VAFMANDANT=:VAFMANDANT"
                        + "   AND VAFART =:VAFART AND VAFFARBE=:VAFFARBE";
                    or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwData["VAFMANDANT"].ToString();
                    or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwData["VAFART"].ToString();
                    or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = dwData["VAFFARBE"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "VAFARBEN";
            Return = Result;
            return Return;
        }
        public DataSet QueryVKKOPF(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VKKOPF";

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM VKKOPF WHERE  "
            + "  VKKMANDANT=:VKKMANDANT AND VKKAUFKRS=:VKKAUFKRS AND VKKAUFLFD=:VKKAUFLFD";
                    or1.Parameters.Add("VKKMANDANT", OracleType.NVarChar).Value = dwData["VKKMANDANT"].ToString();
                    or1.Parameters.Add("VKKAUFKRS", OracleType.NVarChar).Value = dwData["VKKAUFKRS"].ToString();
                    or1.Parameters.Add("VKKAUFLFD", OracleType.NVarChar).Value = dwData["VKKAUFLFD"].ToString();
                    break;
                case 2:
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "VKKOPF";
            }
            Return.Merge(Result);
            return Return;
        }
        public DataSet QueryVKPOS(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VKPOS";
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM VKPOS WHERE  "
                            + "  VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ'  AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD AND VKPAUFPOS=:VKPAUFPOS";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        or1.Parameters.Add("VKPAUFPOS", OracleType.NVarChar).Value = dwData["VKPAUFPOS"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT * FROM VKPOS WHERE  "
                            + "  VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        break;
                    case 3:
                        or1.CommandText = "SELECT VKPMANDANT,KDNAME1,VKKBESTNR,VKKBESTDAT,VKPAUFKRS,VKPAUFLFD,VKPAUFPOS"
                            + ",VKPSA,VKPEZEIT,VKPAENDBEN,VKPAUFMART,VKPVERPART"
                            + ",VKPAENDDAT,VKPNEUBEN,VKPNEUDAT,VKPPOSTYP,VKPARTST,VKPTSTLG,VKPSTLGB,VKPSTLGV"
                            + ",VKPKOLL,VKPART,VKPFARBE,VKPKDFARBNR,VKPMGB,VKPMGV"
                            + ",VKPVERPART||':'||SUBSTR(M.SDDATEN,2,10) AS VKPVERPART,VKPAUFMART||':'||SUBSTR(P.SDDATEN,2,10) AS VKPVERPART"
                            + ",VKPKDARTNR,VKPKDBEZ,VKPMENGE1,VKPZUGET,VKPFREIGE,VKPMEEH,VKPMEEHFKT"
                            + ",VKPMENGE1T1,VKPMENGE1T2,VKPLIEFTERM,VKPVB,VKPPREH,VKPPREIS,VKPWUTERM,VKPWVTERM,VKPPOSWERT"
                            + ",VKPZUSATZ,KDKUNDNA,KDKNAME,KDNAME1"
                            + " FROM VKPOS P JOIN VKKOPF ON   VKKMANDANT=VKPMANDANT AND VKKAUFKRS=VKPAUFKRS AND VKKAUFLFD=VKPAUFLFD"
                            + " LEFT JOIN KDSTAMM ON VKKKUNDNR=KDKUNDNR AND VKKMANDANT=KDMANDANT"
                            + " LEFT JOIN SDDAT M ON VKPMANDANT = SUBSTR(M.SDKEY,1,2)  AND VKPAUFMART = SUBSTR(M.SDKEY,3,3) AND M.SDSA = '0114' AND SUBSTR(M.SDKEY,24,1) = 'V'"
                            + "LEFT JOIN SDDAT P ON VKPMANDANT = SUBSTR(P.SDKEY,1,2)  AND VKPVERPART = SUBSTR(P.SDKEY,3,3) AND P.SDSA = '0209' AND SUBSTR(P.SDKEY,24,1) = 'V'"
                            + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKKSA = '  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD"
                            + " ORDER BY VKPAUFKRS,VKPAUFLFD,VKPAUFPOS ";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        break;
                    case 4:
                        or1.CommandText = "SELECT VKPNEUDAT,KDKUNDNA,VKPKOLL,VAAPRGR,VKPAUFKRS||VKPAUFLFD AS VKPNUM,VAABEZ,VKPMENGE1,VKPWUTERM,VKPNEUBEN,VKPLIEFTERM,VKPPOSTYP"
                            + " FROM VKPOS P LEFT JOIN VAART A ON P.VKPART=VAAART"
                            + " LEFT JOIN KDSTAMM ON VKPKUNDNR= KDKUNDNR"
                            + " WHERE VKPMANDANT=:VKPMANDANT AND VKPSA='  ' AND VKPAUFKRS=:VKPAUFKRS AND VKPNEUDAT>=:VKPNEUDAT ";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPNEUDAT", OracleType.NVarChar).Value = dwData["VKPNEUDAT"].ToString();

                        break;
                    case 5:
                        or1.CommandText = "SELECT * FROM VKPOS WHERE  "
                            + "  VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ'  AND VKPART=:VKPART AND VKPFARBE=:VKPFARBE";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPART", OracleType.NVarChar).Value = dwData["VKPART"].ToString();
                        or1.Parameters.Add("VKPFARBE", OracleType.NVarChar).Value = dwData["VKPFARBE"].ToString();
                        break;
                    case 6:
                        or1.CommandText = "SELECT * FROM VKPOS WHERE  "
                        + "  VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        break; 
                    default:
                        or1.CommandText = "SELECT * FROM VKPOS WHERE  "
                        + "  VKPMANDANT=:VKPMANDANT AND VKPSA <>'AJ' AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VKPOS";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryICC_VKAV95(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "ICC_VKAV95";
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM ICC_VKAV95 WHERE  "
                            + "  VKPMANDANT=:VKPMANDANT AND VKPAUFKRS=:VKPAUFKRS "
                            + " ORDER BY VKPAUF,VKPAUFPOS";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT * FROM ICC_VKAV95 WHERE  VKPMANDANT=:VKPMANDANT AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        break;
                    case 3:
                        or1.CommandText = "SELECT * FROM ICC_VKAV95 WHERE  VKPMANDANT=:VKPMANDANT AND VKPAUFKRS=:VKPAUFKRS AND VKPAUFLFD=:VKPAUFLFD "
                        + " AND VKPAUFPOS=:VKPAUFPOS";
                        or1.Parameters.Add("VKPMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                        or1.Parameters.Add("VKPAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                        or1.Parameters.Add("VKPAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                        or1.Parameters.Add("VKPAUFPOS", OracleType.NVarChar).Value = dwData["VKPAUFPOS"].ToString();
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "ICC_VKAV95";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }

        public DataSet QueryVRKOPF(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM VRKOPF WHERE  "
                            + "  VRKMANDANT=:VRKMANDANT  AND VRKAUFKRS=:VRKAUFKRS AND VRKAUFLFD=:VRKAUFLFD";
                        or1.Parameters.Add("VRKMANDANT", OracleType.NVarChar).Value = dwData["VRKMANDANT"].ToString();
                        or1.Parameters.Add("VRKAUFKRS", OracleType.NVarChar).Value = dwData["VRKAUFKRS"].ToString();
                        or1.Parameters.Add("VRKAUFLFD", OracleType.NVarChar).Value = dwData["VRKAUFLFD"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT DISTINCT VRKRENR FROM VRKOPF K JOIN VRPOS ON K.VRKRENR=VRPRENR WHERE  "
                            + " VRKFIBUKZ='J' AND VRPMANDANT=:VRPMANDANT  AND VRPAUFKRS=:VRPAUFKRS AND VRPAUFLFD=:VRPAUFLFD";
                        or1.Parameters.Add("VRPMANDANT", OracleType.NVarChar).Value = dwData["VRPMANDANT"].ToString();
                        or1.Parameters.Add("VRPAUFKRS", OracleType.NVarChar).Value = dwData["VRPAUFKRS"].ToString();
                        or1.Parameters.Add("VRPAUFLFD", OracleType.NVarChar).Value = dwData["VRPAUFLFD"].ToString();
                        break;
                    case 3:
                        or1.CommandText = "SELECT * FROM VRKOPF WHERE  "
                            + "  VRKMANDANT=:VRKMANDANT  AND VRKRENR=:VRKRENR";
                        or1.Parameters.Add("VRKMANDANT", OracleType.NVarChar).Value = dwData["VRKMANDANT"].ToString();
                        or1.Parameters.Add("VRKRENR", OracleType.NVarChar).Value = dwData["VRKRENR"].ToString();
                        break;
                    default:
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VRKOPF";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryVRPOS(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        break;
                    case 2:
                        or1.CommandText = "SELECT * FROM VRPOS WHERE  "
                            + "  VRPMANDANT=:VRPMANDANT  AND VRPRENR=:VRPRENR";
                        or1.Parameters.Add("VRPMANDANT", OracleType.NVarChar).Value = dwData["VRPMANDANT"].ToString();
                        or1.Parameters.Add("VRPRENR", OracleType.NVarChar).Value = dwData["VRPRENR"].ToString();
                        break;
                    default:
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VRPOS";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryVVLIEF(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VVLIEF";
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM VVLIEF WHERE VVMANDANT=:VVMANDANT AND VVLIEFSCH=:VVLIEFSCH";
                        or1.Parameters.Add("VVMANDANT", OracleType.NVarChar).Value = dwData["VVMANDANT"].ToString();
                        or1.Parameters.Add("VVLIEFSCH", OracleType.NVarChar).Value = dwData["VVLIEFSCH"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT DISTINCT R.VRPRENR,VRPREPOS,VRPAUFKRS,VRPAUFLFD,VRPAUFPOS,VV.* "
                      + " FROM VRPOS R JOIN VVLIEF VV ON R.VRPLIEFSCH=VV.VVLIEFSCH"
                      + " WHERE VRPMANDANT=:VRPMANDANT AND VRPRENR = :VRPRENR";
                        or1.Parameters.Add("VRPMANDANT", OracleType.NVarChar).Value = dwData["VRPMANDANT"].ToString();
                        or1.Parameters.Add("VRPRENR", OracleType.NVarChar).Value = dwData["VRPRENR"].ToString();
                        break;
                    default:
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VVLIEF";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryVVTLIEF(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VVTLIEF";
            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT * FROM VVTLIEF WHERE VVTMANDANT=:VVTMANDANT AND VVTLIEFSCH=:VVTLIEFSCH AND VVTLIEFSCHPOS=:VVTLIEFSCHPOS";
                        or1.Parameters.Add("VVTMANDANT", OracleType.NVarChar).Value = dwData["VVTMANDANT"].ToString();
                        or1.Parameters.Add("VVTLIEFSCH", OracleType.NVarChar).Value = dwData["VVTLIEFSCH"].ToString();
                        or1.Parameters.Add("VVTLIEFSCHPOS", OracleType.NVarChar).Value = dwData["VVTLIEFSCHPOS"].ToString();
                        break;
                    case 2:
                        or1.CommandText = "SELECT * "
                                           + " FROM VVTLIEF   WHERE "
                                           + " VVTAUFKRS = :VVTAUFKRS AND VVTAUFLFD = :VVTAUFLFD ";
                        or1.Parameters.Add("VVTAUFKRS", OracleType.NVarChar).Value = dwData["VVTAUFKRS"].ToString();
                        or1.Parameters.Add("VVTAUFLFD", OracleType.NVarChar).Value = dwData["VVTAUFLFD"].ToString();
                        break;
                    case 3:
                        or1.CommandText = "SELECT * FROM VVTLIEF WHERE VVTMANDANT=:VVTMANDANT AND VVTLIEFSCH=:VVTLIEFSCH";
                        or1.Parameters.Add("VVTMANDANT", OracleType.NVarChar).Value = dwData["VVTMANDANT"].ToString();
                        or1.Parameters.Add("VVTLIEFSCH", OracleType.NVarChar).Value = dwData["VVTLIEFSCH"].ToString();
                        break;
                    case 4:
                        or1.CommandText = "SELECT DISTINCT R.VRPRENR,VRPREPOS,VRPAUFKRS,VRPAUFLFD,VRPAUFPOS,VV.* "
                        + " FROM VRPOS R JOIN VVTLIEF VV ON R.VRPLIEFSCH=VV.VVTLIEFSCH"
                        + " WHERE VRPMANDANT=:VRPMANDANT AND VRPRENR = :VRPRENR ";
                        or1.Parameters.Add("VRPMANDANT", OracleType.NVarChar).Value = dwData["VRPMANDANT"].ToString();
                        or1.Parameters.Add("VRPRENR", OracleType.NVarChar).Value = dwData["VRPRENR"].ToString();
                        break;
                }
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VVTLIEF";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryVVPACK(DataRow dwData)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VVPACK";  //VVPMANDANT	VVPLIEFSCH	VVPPACKNR
            try
            {
                or1 = OracleDB.CreateCommand();

                or1.CommandText = "SELECT * FROM VVPACK WHERE VVPMANDANT=:VVPMANDANT AND VVPLIEFSCH=:VVPLIEFSCH AND VVPPACKNR=:VVPPACKNR";
                or1.Parameters.Add("VVPMANDANT", OracleType.NVarChar).Value = dwData["VVPMANDANT"].ToString();
                or1.Parameters.Add("VVPLIEFSCH", OracleType.NVarChar).Value = dwData["VVPLIEFSCH"].ToString();
                or1.Parameters.Add("VVPPACKNR", OracleType.NVarChar).Value = dwData["VVPPACKNR"].ToString();
                Result = Connect2Proxy(or1);
                if (Result.Tables.Count > 0)
                {
                    tbLocal = Result.Tables[0];
                    tbLocal.TableName = "VVPACK";
                }
                Return.Merge(Result);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return Return;
        }
        public DataSet QueryVERSART(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            string TableName = "VERSART";
            OracleCommand or1;

            try
            {
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 1:
                        or1.CommandText = "SELECT* FROM VERSART WHERE VVERSART=:VVERSART AND VSPED=:VSPED";
                        or1.Parameters.Add("VVERSART", OracleType.NVarChar).Value = dwData["VVERSART"].ToString();
                        or1.Parameters.Add("VSPED", OracleType.NVarChar).Value = dwData["VSPED"].ToString();
                        break;
                    default:
                        break;
                }
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = TableName;
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }

        //WDECK WBBST WBBEW VVLIEF VVTLIEF
        #endregion
        #region======X==============
        public DataSet QueryICC_XDECK(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();
            string table = "VKKOPF";

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "SELECT * FROM ICC_XDECK WHERE  "
            + "  MANDANT=:MANDANT AND KRS=:KRS AND LFD=:LFD AND POS=:POS AND UPOS=:UPOS";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"].ToString();
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"].ToString();
                    or1.Parameters.Add("POS", OracleType.NVarChar).Value = dwData["POS"].ToString();
                    or1.Parameters.Add("UPOS", OracleType.NVarChar).Value = dwData["UPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM ICC_XDECK WHERE  "
            + "  MANDANT=:MANDANT AND KRS=:KRS AND LFD=:LFD ";
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("KRS", OracleType.NVarChar).Value = dwData["KRS"].ToString();
                    or1.Parameters.Add("LFD", OracleType.NVarChar).Value = dwData["LFD"].ToString();

                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ICC_XDECK";
            }
            Return.Merge(Result);
            return Return;
        }
        #endregion
        #region======Z==============
        public DataSet QueryZABED(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ZABED WHERE ZABMANDANT=:ZABMANDANT AND ZABNR=:ZABNR"; ;
                    or1.Parameters.Add("ZABMANDANT", OracleType.NVarChar).Value = dwData["ZABMANDANT"].ToString();
                    or1.Parameters.Add("ZABNR", OracleType.NVarChar).Value = dwData["ZABNR"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ZABED";
            Return = Result;
            return Return;
        }
        public DataSet QueryZUTEI(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ZUTEI WHERE ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD AND ZUAUFPOS=:ZUAUFPOS"; ;
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    or1.Parameters.Add("ZUAUFPOS", OracleType.NVarChar).Value = dwData["ZUAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM ZUTEI WHERE ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD AND ZUAUFPOS=:ZUAUFPOS"; ;
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    or1.Parameters.Add("ZUAUFPOS", OracleType.NVarChar).Value = dwData["ZUAUFPOS"].ToString();
                    break;
                case 4:
                    or1.CommandText = " SELECT * FROM ZUTEI WHERE ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD"; ;
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "  SELECT DISTINCT ZUAUFKRS,ZUAUFLFD,ZUAUFPOS,ZUSA,ZUPOS,ZUSPPART,GLLO,GLLB,GLLP,SUM(ZUEINTKG-ZUENTNKG) AS TOGET,"
                    + "SUM(ZUEINTKG) AS ZUEINTKG,SUM(ZUENTNKG) AS ZUENTNKG,MAX(LSLIEFNA) AS SELLER "
                    + " from zutei Z JOIN GLLG B  ON ZULBEHI=GLLBEHI "
                         + " LEFT JOIN GPDAT ON GPPARTIE=ZUPARTIE  "
                         + "  LEFT JOIN LIEFDAT ON GPLIEFNR=LSLIEFNR "
                         + " WHERE ZUMANDANT=:ZUMANDANT AND ZUAUFKRS=:ZUAUFKRS AND ZUAUFLFD=:ZUAUFLFD AND ZUFLAG='S' AND ZUEINTKG-ZUENTNKG>0"
                         + " GROUP BY ZUAUFKRS,ZUAUFLFD,ZUAUFPOS,ZUSA,ZUPOS,ZUSPPART,GLLO,GLLB,GLLP";
                    or1.Parameters.Add("ZUMANDANT", OracleType.NVarChar).Value = dwData["ZUMANDANT"].ToString();
                    or1.Parameters.Add("ZUAUFKRS", OracleType.NVarChar).Value = dwData["ZUAUFKRS"].ToString();
                    or1.Parameters.Add("ZUAUFLFD", OracleType.NVarChar).Value = dwData["ZUAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ZUTEI";
            Return = Result;
            return Return;
        }

        #endregion
        #region===ICC============
        //ICC_FOLDERS;ICC_MENUDEF; ICC_FUNCTIONS
        public DataSet QueryICC_FOLDERS(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ICC_FOLDERS WHERE MANDANT=:MANDANT AND ROWNID=:ROWNID"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("ROWNID", OracleType.NVarChar).Value = dwData["ROWNID"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM ICC_FOLDERS WHERE MANDANT=:MANDANT AND COMPANY=:COMPANY"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("COMPANY", OracleType.NVarChar).Value = dwData["COMPANY"].ToString();
                    break;
                case 9999:
                    or1.CommandText = " SELECT * FROM ICC_FOLDERS WHERE MANDANT=:MANDANT"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_FOLDERS";
            Return = Result;
            return Return;
        }
        public DataSet QueryICC_MENUDEF(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT  AND ROWNID=:ROWNID"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("ROWNID", OracleType.NVarChar).Value = dwData["ROWNID"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT AND COMPANY=:COMPANY AND USERID=:USERID"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("COMPANY", OracleType.NVarChar).Value = dwData["COMPANY"].ToString();
                    or1.Parameters.Add("USERID", OracleType.NVarChar).Value = dwData["USERID"].ToString();
                    break;
                case 3:
                    or1.CommandText = " SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT AND COMPANY=:COMPANY"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("COMPANY", OracleType.NVarChar).Value = dwData["COMPANY"].ToString();
                    break;
                case 9999:
                    or1.CommandText = " SELECT * FROM ICC_MENUDEF WHERE MANDANT=:MANDANT AND COMPANY=:COMPANY"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("COMPANY", OracleType.NVarChar).Value = dwData["COMPANY"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_MENUDEF";
            Return = Result;
            return Return;
        }
        public DataSet QueryICC_FUNCTIONS(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = " SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT AND ROWNID=:ROWNID"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("ROWNID", OracleType.NVarChar).Value = dwData["ROWNID"].ToString();
                    break;
                case 2:
                    or1.CommandText = " SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT AND TYPE=:TYPE"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    or1.Parameters.Add("TYPE", OracleType.NVarChar).Value = dwData["TYPE"].ToString();
                    break;
                case 9999:
                    or1.CommandText = " SELECT * FROM ICC_FUNCTIONS WHERE MANDANT=:MANDANT"; ;
                    or1.Parameters.Add("MANDANT", OracleType.NVarChar).Value = dwData["MANDANT"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "ICC_FUNCTIONS";
            Return = Result;
            return Return;
        }
        #endregion
    }
}

